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\n",cnt);
    return 0;
}

 

posted @ 2015-08-30 09:36  陈瑞宇  阅读(92)  评论(0编辑  收藏  举报