题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1205
要能全部吃完,最多的必须要吃完,所以max - 1 <= sum - max....
此题sum可能会溢出, 要用long long
#include <stdio.h>
int main(void)
{
int t, n, max, sweet;
long long sum;
scanf("%d", &t);
while (t--) {
max = -1;
sum = 0;
scanf("%d", &n);
while (n--) {
scanf("%d", &sweet);
if (sweet > max)
max = sweet;
sum += sweet;
}
sum -= max;
if (max - 1 <= sum)
puts("Yes");
else
puts("No");
}
return 0;
}