首页 > 其他 > 详细

Codeforces Round #318 (Div. 2) A Bear and Elections

时间:2015-08-30 09:52:28      阅读:182      评论:0      收藏:0      [点我收藏+]

优先队列模拟一下就好。

#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;
}

 

Codeforces Round #318 (Div. 2) A Bear and Elections

原文:http://www.cnblogs.com/jerryRey/p/4770263.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!