`
bcyy
  • 浏览: 1823339 次
文章分类
社区版块
存档分类
最新评论

杭电1205

 
阅读更多

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1205

提示:只要除了数目最多的糖果max之外,其余糖果数目的和(注意要用int64)加1大于等于max,则能吃完,否则不能。

C语言源码:

#include<stdio.h>
#include<math.h>
int main()
{
	_int64 t,n,i,sum,max,a;
	while(scanf("%I64d",&t)!=EOF)
	{
		while(t--)
		{
			scanf("%I64d",&n);
			sum=0;
			max=0;
			for(i=1;i<=n;i++)
			{
				scanf("%I64d",&a);
				sum+=a;
				max=(max<a?a:max);
			}
			if(sum-max+1>=max)
				printf("Yes\n");
			else
				printf("No\n");

		}
	}
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics