标签:
优先队列模拟一下就好。
#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