ZOJ 3519 Who is the Smartest Man(贪心 水)

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3519

 

题意 :caocao能够战胜每一个人 战胜智商比他高的加2点智商 否则加1点

         问经过辩论后能得到的最高智商值为多少

 

思路:在辩论中一直和智商比自己高的比 把比自己低的放在最后就能得到最高智商

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int score[1000];
int main()
{
    int n,now;
    while(scanf("%d%d",&n,&now)!=EOF)
    {
        int i,j,k;
        int add1,add2;
        for(i=0;i<n;i++) scanf("%d",&score[i]);
        sort(score,score+n);
        for(i=0;i<n;i++)
        {
            if(score[i]>now)
            {
                break;
            }
        }
        add1=i;
        add2=0;
        for(j=i;j<n;j++)
        {
            if(now<score[j])
            {
                now+=2;
            }
            else
            {
                add2++;
            }
        }
        //printf("%d\n",now);
        now+=(add1+add2);
        printf("%d\n",now);
    }
    return 0;
}
View Code

 

posted @ 2015-01-23 10:19  sola94  阅读(127)  评论(0编辑  收藏  举报