hdu 4974 A simple water problem

有n个人,进行了若干场比赛,每场比赛每个人可以得0分或1分,给出每个人的得分,求至少进行了多少场比赛。

就是两两配对,如果最大的比总数的一半还大,那么答案就是最大的数,否则就是总数的一半。

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int cas,n;
    scanf("%d",&cas);
    int now=0;
    while(cas--)
    {
        now++;
        scanf("%d",&n);
        int sum=0,x,mm=-1;;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            mm=max(mm,x);
            sum+=x;
        }
        printf("Case #%d: %d
",now,max ( mm, (sum+1)/2 ));
    }
    return 0;
}
原文地址:https://www.cnblogs.com/vermouth/p/4004092.html