Timon & Pumba
All submissions for this problem are available.
Timon and Pumba from Lion's King, found new type of bugs. Since both of them are fond of eating bugs & this being a really yummy one.
They decided to collect as many as possible & then divide among themselves.
Each of the bug has a yumminess attached to it, i.e. two bugs with yumminess X & Y respectively, where X > Y means that bug with yumminess X is more yummy.
Timon & Pumba both learnt addition of numbers in binary at school. Given two numbers X & Y in decimal, they will convert them to binary & add them.
Timon is good at math but Pumba is a bit weak. He didn't learn the addition properly. Instead of forwarding the carry obtained from addition of bits at same position, he forgets it.
eg 4 + 6 = 2 100 + 110 = 010
At most significant bit, he forgot to take care of the carry.
Not only this he forgets it any other position too.
11 + 6 = 13 1011 + 0110 = 1101
Timon know the situation & he wants to utilize his knowledge to get the maximum he can get. He'll divide the collection they get into two sets keeping these things into mind but he'll try to maximize the sum for his share. He'll also calculate the sum infront of Pumba to show that they both got equal share (ofcourse via Pumba's method). Sometimes its not possible to divide the collection.
But here's the situation, Timon is too lazy. He needs your help to get this division done. Can you help him?
he first line of the input gives the number of test cases, T. T test cases follow. Each test case is described in two lines.
The first line contains a single integer N, denoting the number of bugs they collected. The next line contains the N integers Ci
separated by single spaces, which denote the yumminess of each bug.
For each test case, output one line with total yumminess of the share Timon will keep. If it's not possible for Timon to divide equally, "NO" should be printed without the quotes on that line.
- 1 ≤ T ≤ 100
- 1 ≤ Ci ≤ 10^6
- 2 ≤ N ≤ 1000
Input: 2 3 2 4 6 5 1 2 3 4 5 Output: 10 NO
|Time Limit:||0.137903 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, CLOJ, FS|
Fetching successful submissions