#P3878. [TJOI2010] 分金币
[TJOI2010] 分金币
Description
There are coins, which may have different values. The value of the -th coin is .
Now we need to split them into two parts such that the difference in the numbers of coins does not exceed . What is the minimum possible difference between the total values of the two parts?
Input Format
This problem contains multiple sets of testdata within a single test point.
The first line contains a positive integer , denoting the number of test cases in this test point.
For each test case:
Each test case consists of two lines.
The first line contains an integer , denoting the number of coins.
The second line contains integers. The -th integer denotes the value of the -th coin.
Output Format
For each test case, output one line with a single integer denoting the answer.
2
3
2 2 4
4
1 2 3 6
0
2
Hint
Constraints
- For of the data, it is guaranteed that .
- For of the testdata, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号