QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#503635 | #9129. Quotient Sum | ucup-team191# | RE | 0ms | 0kb | C++23 | 841b | 2024-08-03 21:32:31 | 2024-08-03 21:32:32 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=300010,MOD=1e9+7,MT=1;
const char en='\n';
const ll LLINF=1ll<<60;
int n,t;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (MT) cin>>t;
else t=1;
while (t--)
{
cin>>n;
vl v(n);
for (auto&x: v) cin>>x;
sort(all(v));
vl dp(n);
for (int i=n-2;i>=0;--i)
{
if (v[n-1]/v[i]==1)
{
dp[i]=1;
continue;
}
int j=lower_bound(all(v),v[i]*2)-v.begin();
int k=lower_bound(all(v),v[i]*(v[j]/v[i]+1))-v.begin();
dp[i]=dp[k-1]+(v[k-1]/v[i]);
if (j!=i+1) dp[i]=min(dp[i],dp[j-1]+(v[j-1]/v[i]));
}
cout<<dp[0]<<en;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 2 3 6