OpenJudge

216:Balanced Game

总时间限制:
3000ms
内存限制:
65536kB
描述

Fungi is going to hold a game among his friends. In the game his n (n is even) friends will be divided into two opponent groups. The two groups have exactly the same number of players. To make the game more exciting, it would be better to split the players in such a way that the absolute level difference between the two groups is minimum. Each player has a known level Li, and the level of a group is defined by the sum of all the levels of the group members. Can you help Fungi?

输入
The first line has an integer T, the number of test cases (T<=20).
Each test case has one even integer n on the first line (2<=n<=50). The next line has n integers, the i-th representing Li. 0<=Li<=100.
输出
For each case, output the the minimum level difference Fungi can achieve for the game.
样例输入
2
4
1 2 8 9
6
2 3 1 5 2 4
样例输出
0
1

专题系列题标含义:
目前已推出的题目:
DG:递归,LB:链表,DZ :队列和栈,TR:二叉树
下面的题目将在集训后再推出:
DF:深搜,BF:广搜
DI:单源最短路径,FL:多源最短路径
DP:动态规划

全局题号
5875
添加于
2016-12-24
提交次数
8
尝试人数
4
通过人数
0