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

 

转载于:https://www.cnblogs.com/sola1994/p/4243445.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值