简单模拟题。找规律,只要最大的那个数max-(s-max)<=1即可全部吃完。

CODE:

 #include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

const int maxn = 1000001;
int a[maxn];


int main()
{
    int T;
    int n;
    __int64 s;        //定义为__int64,要不会WA 
    scanf("%d", &T);
    while(T--)
    {
        int i;
        s = 0;
        __int64 max = -1;     
        scanf("%d", &n);
        for(i = 0 ; i < n ; i++)
        {
            scanf("%d", &a[i]);
            if(a[i] > max)
            {
                max = a[i];
            }
            s += a[i];
        }
        __int64 x = 2*max - s;           //
        printf(x <= 1?"Yes\n":"No\n");
    }
    return 0;
}
posted on 2012-07-18 21:30  有间博客  阅读(110)  评论(0编辑  收藏  举报