75WA,求调
查看原帖
75WA,求调
1360723
lyl__lxly楼主2025/1/19 19:49
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n;
	cin>>n;
	vector<int>v;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	int cnt=0,sum=0;
	for(int i=0;i<v.size();++i){
		if(sum+v[i]>=(cnt+1+1)*(cnt+1)/2) sum+=v[i],++cnt;
		//cout<<sum<<endl;
	}
	cout<<cnt;
}
2025/1/19 19:49
加载中...