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 = 2; i <= n; i++){
        int v; scanf("%d",&v);
        q.push(v);
    }
    int cnt = 0;
    while(q.top()>=t){
        t++; cnt++;
        int v = q.top();
        q.pop(); q.push(v-1);
    }
    printf("%d
",cnt);
    return 0;
}
原文地址:https://www.cnblogs.com/jerryRey/p/4770263.html