P11886 「Stoi2025」爱你没差
xiaoqimingbozai · · 个人记录
#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;
}