QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#476151#9129. Quotient Sumucup-team3510#Compile Error//C++14698b2024-07-13 17:59:032024-07-13 17:59:03

Judging History

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

  • [2024-09-26 15:38:30]
  • hack成功,自动添加数据
  • (/hack/908)
  • [2024-07-13 17:59:03]
  • 评测
  • [2024-07-13 17:59:03]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
long long a[200010],f[200010];
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	memset(f,0x3f,sizeof(f)),f[n]=0;
	v.emplace_back(n);
	for(int i=n-1,last=n;i;i--)
	{
		for(int j=v.size()-1;j>=0;j--)
		{
			f[i]=min(f[i],f[v[j]]+a[v[j]]/a[i]);
		}
		for(int j=v.size()-1;j>=0;j--)
		{
			if(f[v[j]]+a[v[j]]/a[i]>f[i])
			{
				v.erase(v.begin()+j);
			}
		}
		if(f[i+1]+a[i+1]/a[i]<=f[i])
		{
			f[i]=f[i+1]+a[i+1]/a[i];
			v.emplace_back(i+1);
		}
	}
	cout<<f[1]<<endl;
	return 0;
}

Details

answer.code:7:1: error: ‘vector’ does not name a type
    7 | vector<int> v;
      | ^~~~~~
answer.code: In function ‘int main()’:
answer.code:19:9: error: ‘v’ was not declared in this scope
   19 |         v.emplace_back(n);
      |         ^