zoukankan      html  css  js  c++  java
  • 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
    ",now);
            now+=(add1+add2);
            printf("%d
    ",now);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    第22章 算法
    第二十一章 数据结构
    mysql 索引
    MySQL 视图
    MySQL 子查询
    MySQL 批量更新数据
    MySQL 默认值
    Spring 整体架构和环境搭建
    python之字符串
    python学习
  • 原文地址:https://www.cnblogs.com/sola1994/p/4243445.html
Copyright © 2011-2022 走看看