Rann-Neeti

0

0 votes
Problem

In the greatest epic Mahabharata, Before the Kurukshetra war started both the Kauravas and the Pandavas were trying to get the support of more and more kings from far and wide. Arjuna and Duryodhana both went to Lord Krishna's home Dwarka to take help from him, but at that time Krishna was taking a nap. Duryodhana went and took a seat beside his head and waited for him to wake up. At the same time, Arjuna also came to Krishna to ask his support for the Pandavas. Arjuna was very humble and sat near Krishna's feet. When Krishna woke up, he saw Arjuna first and asked him what he wanted. Arjuna asked for his help in the war. Duryodhana said, "I came before Arjuna, so you should help me and not Arjuna." Krishna said, "Due to your pride you sat beside my head so I saw Arjuna first”. But as both of them were dear to him, he decided to help them both by dividing hi Narayani Sena in such a way that he is not unfair to any one of them. Narayani Sena consisted of various troops of varied skill level. Your task is to decipher Krishna’s Rann-neeti in dividing his army in two parts such that the number of troop in one part may should not exceed the other part by more than one. Also the difference in total strength(total skills of troops in a part) between both parts should be minimum. The First part of the Narayani Sena with smaller or equal strength to the other will be given to Arjuna as Krishna will be on his side to guide him in the war as he was younger and asked for his help first. The other part with equal or greater strength will be given to Duryodhana.
Input:
The first line of input will contain the number of test cases 'T'. This is followed by 'T' test cases.
Each test case starts by N, the total number of troops in Naryani Sena.
N lines will follow with Si being skill level of ith troop in Krishna's army.
Output:
Your output should be exactly T lines.
Output of each test case should contain 2 numbers first being the total skill of part given to Arjuna and the other being total skill-points of the part of Narayani Sena given to Duryodhana.

Constraint:
1<=T<=100
1<=N<=100
1<=Si<=450

Note: Event referred in above question is made for programming purposes only.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?