QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526291#9176. Non-Interactive Nimhnust_xiaoqiWA 0ms3712kbC++20752b2024-08-21 12:59:312024-08-21 12:59:33

Judging History

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

  • [2024-08-21 12:59:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2024-08-21 12:59:31]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

const int N = 2e5;

typedef long long LL;
typedef pair<int, int> PII;

LL d[N];

void solve() {
	LL n,m;
	cin>>n>>m;
	LL m2=m;
	for(LL i=1;i<=n;++i){
		cin>>d[i];
	}
	sort(d+1,d+n+1);
	LL ans=0;
	for(LL i=1;i<=n;++i){
		LL data=(m%i!=0)+m/i;
		if(data>=d[i]){
			m-=d[i];
		}else{
			ans=i-1;
			break;
		}
	}
	if(!n) ans=n;
	LL cnt=1;
	m=m2;
	for(LL i=n;i;--i){
		LL data=(m%cnt!=0)+m/cnt;
		if(data>=d[i]){
			m-=d[i];
			++cnt;
		}
	}
	ans=min(ans,cnt-1);
	cout<<ans<<endl;
}

signed main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0);
	
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

input:

2
4
4 2 7 1
4
1 1 1 1

output:

1

result:

wrong output format Unexpected end of file - int32 expected (test case 1)