TECHLN5 - Freedom!

no tags 

 

Victory at all costs, victory in spite of all terror, victory however long and hard the road may be; for without victory, there is no survival.
-Winston Churchill

Inspired by this quote, the students of NSIT plan on attacking the alien warship and putting an end to the oppression, once and for all.

The plan is to attack the aliens from both flanks and kill em all. Two teams are going to be made for this task. The leader of our forces, Ayush, wants the two attack parties led by Arpit and Gaurav to be of similar strengths.

First line of input will contain an integer t, the number of testcases. For each test case first line gives an integer n, the size of the total army, following n lines will contain the strength of each student.

Input:

First line of input will contain an integer t, the number of testcases. For each test case first line gives an integer n, the size of the total army, following n lines will contain the strength of each student.

Output:

You have to print the absolute difference in strengths of the most optimum division of each set into 2 subsets.

1<=t<=50 

0< Total number of students <= 500 and 0< strength <=500

Sample:

Input:
2
5
13
53
19
397
181
8
41
43
47
79
83
443
167
239

Output:
131
4


hide comments
andrzej_d: 2017-09-20 19:54:21

Last edit: 2017-09-21 15:38:19

Added by:Tarun Gehlaut
Date:2013-04-19
Time limit:0.509s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:CSI NSIT