Hdu 1205 eats candy
Eat candy
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission (s): 25141 Accepted Submission (s): 7162
Problem DescriptionHOHO, finally won all the sweets from the Speakless hand. It is a special hobby for Gardon to eat candy, that is, they do not like to put the same candy together, they like to eat one first, the next time you eat the other one, this way; but Gardon doesn't know if there is a sequence of eating candy so that he can finish all the candy? Please write a program for computation.
The first line of Input has an integer T, followed by T group of data, each group of data occupies 2 rows, the first row is an integer N (0
Output outputs a row for each group of data, including a "Yes" or "No ".
Sample Input
234 1 155 4 3 2 1
Sample Output
NoYes
#include
#include
using namespace std;typedef long long ll;int main(){ int T; cin>>T; while(T--){ int n; cin>>n; ll sum=0,max=0,num; for(int i=0;i
>num; sum+=num; if(num>max) max=num; } if(sum-max>=max-1) cout<<"Yes\n"; else cout<<"No\n"; } return 0;}