codeforce好地方啊 Bear and Elections *

Codeforces Round #318

 

居然可以看测试数据,哪里没过一目了然,哈哈哈

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<queue>
 7 #include<map>
 8 using namespace std;
 9 #define MOD 1000000007
10 const int INF=0x3f3f3f3f;
11 const double eps=1e-5;
12 typedef long long ll;
13 #define cl(a) memset(a,0,sizeof(a))
14 #define ts printf("*****\n");
15 const int MAXN=1005;
16 int n,m,tt;
17 struct Node
18 {
19     int id,x;
20     void in(int i)
21     {
22         scanf("%d",&x);
23         id=i;
24     }
25     friend bool operator<(Node a,Node b)
26     {
27         if(a.x==b.x)    return a.id<b.id;
28         else return a.x<b.x;
29     }
30 }node[MAXN];
31 int main()
32 {
33     int i,j,k,ca=1;
34     #ifndef ONLINE_JUDGE
35     freopen("1.in","r",stdin);
36     #endif
37     while(scanf("%d",&n)!=EOF)
38     {
39         priority_queue<Node> q;
40         for(i=0;i<n;i++)
41         {
42             node[i].in(i);
43             q.push(node[i]);
44         }
45         int tot=0;
46         while(1)
47         {
48             Node now=q.top();
49             q.pop();
50             if(node[0].x+tot>now.x||now.id==0)
51             {
52                 break;
53             }
54             now.x-=1;
55             tot++;
56             q.push(now);
57         }
58         printf("%d\n",tot);
59     }
60 }

 

posted @ 2015-09-21 14:40  miao_a_miao  阅读(208)  评论(2编辑  收藏  举报