Hdu 1205 eats candy

Source: Internet
Author: User

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;}
    
   
  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.