PROBLEM LINKS:DIFFICULTY:CAKEWALK PREREQUISITES:Basic knowledge of arrays and loops. PROBLEM:The program asks you to calculate if all the elephants would get the number of candies that they want. EXPLANATION:If there are C candies in all, and elephant i needs A[i] candies, then it is possible to serve all the elephants only if there are enough candies available, i.e. the following condition must be satisfied:
This means you can have a simple loop over the array A to count the sum of the required number of candies by the elephants and then finally comparing it with C to determine the answer. If the above condition is satisfied, answer will be Yes, else the answer will be No (they have to be casesensitive to avoid WA). SETTER'S SOLUTION:Can be found here. APPROACH:The problem setter used the above solution to solve the problem.TESTER'S SOLUTION:Can be found here. APPROACH:The problem tester used the above solution to solve the problem.
This question is marked "community wiki".
asked 11 Jun '12, 22:15

include <stdio.h>int main(){ int t,n,i,j; int A[1000]; long long int c; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&n); scanf("%lli",&c); for(j=0;j<n;j++){ scanf("%d",&A[j]); c=cA[j]; } if(c<0){ printf("No\n"); } else{ printf("Yes\n"); } } return 0; } answered 14 Oct, 21:19

really nice, waiting for the next editorials ;)
This can't be better!! :D