http://acm.hdu.edu.cn/showproblem.php?pid=1205
详细解说原理。http://blog.csdn.net/hnust_xiehonghao/article/details/8005832
鸽巢原理:
2max-sum<=1;
(sum-max+1)>max;
Time
Limit: 6000/3000 MS (Java/Others) Memory Limit:
65535/32768 K (Java/Others)
Total Submission(s):
21940 Accepted Submission(s):
6264
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 |
#include<iostream> #include<algorithm> using
namespace std; int main() { __int64
t,sum,n,x,max,i; cin>>t; while (t--) { max=sum=0; cin>>n; for (i=0;i<n;i++) { cin>>x; sum+=x; if (max<x) max=x; } if (2*max-sum<=1) cout<< "Yes" <<endl; else cout<< "No" <<endl; } return
0; } |
原文:http://www.cnblogs.com/cancangood/p/3681666.html