码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 1205 吃糖果

时间:2014-09-12 10:15:33      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:mathematics

水题,问题是 lld 不管是交G++还是C++都要WA。


我还是以为我做错了呢,改成 I64d 就AC了。


找出最多的糖,然后吃一颗这个,再吃其他的。只要其他的糖不比最多的糖少就满足了。


#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<stack>
#include<iostream>
#include<list>
#include<set>
#include<cmath>

#define INF 0x7fffffff
#define eps 1e-8
#define LL long long
#define PI 3.141592654
#define CLR(a,b) memset(a,b,sizeof(a))
#define FOR(n) for(int i=0;i<n;i++)
#define debug puts("==fuck==")
#define acfun std::ios::sync_with_stdio(false)

using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        LL maxn=0,sum=0,tmp;
        FOR(n)
        {
            scanf("%I64d",&tmp);
            sum+=tmp;
            maxn=max(maxn,tmp);
        }
        if(sum-maxn>=maxn-1)
            puts("Yes");
        else
            puts("No");
    }
}


HDU 1205 吃糖果

标签:mathematics

原文地址:http://blog.csdn.net/dongshimou/article/details/39225937

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!