Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)

时间:2023-03-09 16:21:37
Codeforces Round #318 (Div. 2) A 	 Bear and Elections (优先队列模拟,水题)

优先队列模拟一下就好。

#include<bits/stdc++.h>
using namespace std; priority_queue<int>q; int main()
{
int n;
scanf("%d",&n);
int t; scanf("%d",&t);
for(int i = ; i <= n; i++){
int v; scanf("%d",&v);
q.push(v);
}
int cnt = ;
while(q.top()>=t){
t++; cnt++;
int v = q.top();
q.pop(); q.push(v-);
}
printf("%d\n",cnt);
return ;
}