吃糖果 HDU - 1205 思维

HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。

input

2
3
4 1 1
5
5 4 3 2 1

output

No
Yes

code

//Siberian Squirrel
//#include<bits/stdc++.h>
//#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<set>
#include<string>

#define ACM_LOCAL

using namespace std;
typedef long long ll;

const double PI = acos(-1);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
const int UP = 1e2 + 10;

int a[N];

inline bool solve(int n, ll res = 0) {
    int maxx = 0;
    for(int i = 1; i <= n; ++ i) {
        scanf("%d", &a[i]);
        res += a[i];
        maxx = max(maxx, a[i]);
    }
    if(maxx - 1 <= res - maxx) return true;
    return false;
}

int main() {
#ifdef ACM_LOCAL
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif
    int o = 1, n;
    scanf("%d", &o);
    while(o --) {
        scanf("%d", &n);
        printf("%s\n", solve(n)? "Yes": "No");
    }
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值