QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#503635#9129. Quotient Sumucup-team191#RE 0ms0kbC++23841b2024-08-03 21:32:312024-08-03 21:32:32

Judging History

你现在查看的是最新测评结果

  • [2024-09-26 15:38:30]
  • hack成功,自动添加数据
  • (/hack/908)
  • [2024-08-03 21:32:32]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-08-03 21:32:31]
  • 提交

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

output:


result: