跳到正文

个人记录

P11886 「Stoi2025」爱你没差

xiaoqimingbozai约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年3月18日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int n,m;
priority_queue<ull,vector<ull>,greater<ull> >q;
ull ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		ull t;
		scanf("%llu",&t);
		q.push(t);
	}
	while(q.size()>1)
	{
		ull x=q.top();
		q.pop();
		ull y=q.top();
		q.pop();
		q.push(x+y);
		ull p=y/m;
		if(x>p) ans++;
		else if(p*m==y&&x>=p) ans++;
	}
	printf("%llu",ans);
	return 0;
}
原文