Eat candy
Time limit:6000/3000 MS (java/others) Memory limit:65535/32768 K (java/others)
Total submission (s): 27178 Accepted Submission (s): 7691
Problem Descriptionhoho, finally from Speakless hand to win all the candy, is Gardon eat candy when there is a special hobby, is not like the same candy put together to eat, like to eat first, the next time to eat another, so But Gardon don't know if there is a candy-eating order so he can finish all the candies? Please write a program to help calculate.
Input first line has an integer t, the next T-group data, each group of data accounted for 2 rows, the first row is an integer n (0<n<=1000000), the second row is n number, indicating the number of n candies Mi (0<mi<=1000000).
Output for each set of data, outputs a line that contains a "Yes" or "No".
Sample Input
234 1 155 4 3 2 1
Sample Output
NoYesHintHintuse function scanf
Authorgardon is very easy to think as long as all the sweets in the largest one with the rest of the candy can be separated, do not know why--int64 always mutation error instead of a double time-out and then write in C just past
#include <stdio.h>int main () {int t;scanf ("%d", &t), while (t--) {double sum=0;int n,max=-1,t;scanf ("%d",& N); for (int i=0;i<n;i++) {scanf ("%d", &t); Sum+=t;if (T>max) max=t;} Sum-=max;if (sum>=max-1) printf ("yes\n"); elseprintf ("no\n");} return 0;}
Hangzhou electric HDU 1205 eat sweets