Gopal and his Crying Sons
All submissions for this problem are available.
Gopal recently went to foriegn trip and he brought some chocolates to his 3 sons.
His 3 sons, as soon as they get their part of chocolates,they start summing up their prices.
If any one of the sons gets their price less than the (total price)/3 then he will start crying.
Gopal obviously hates to see them cry.So he tells you to check whether it is possible to devide
chocolates such that each gets (total)/3 or not.You may choose a chocolate not to include in any distribution.
Input: t number of test cases. In each test case n. Next line n space seperated integers. Output. t lines containing "Yes" or "No".(quotes for clarity only) Constraints: 1<= t <= 10 1<= n <= 100 sum of prices will be less than 1000 and guarenteed to be divisible by 3.Sample input: 3 7 1 2 3 4 4 5 8 4 1 3 2 3 3 1 2 3 Sample Output: Yes Yes No Note: 1st case distribute (1,8) (2,3,4) (4,5) each sum to 9. 2nd case distribute (1,2) (3) (3) each sum to 3 3rd case not possibe to distribute.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.