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:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.