Masala #ISVH2VQVWI
Tarjima qilib ishlang #2
It's the annual school sports festival, and the final, most anticipated event is the Tug-of-War championship! As the coach of the reigning champions, you have n students who have signed up to participate.
To ensure the competition is as fair and thrilling as possible, you need to divide all n students into two teams. The strength of each student is known. The total strength of a team is simply the sum of the strengths of its members. Your goal is to form the two teams in such a way that the absolute difference between their total strengths is minimized.
You must assign every student to exactly one of the two teams.
The first line contains a single integer n, the number of students available. 1 ≤ n ≤ 20.
The next line contains n integers, p1,p2,…,pn, representing the strength of each student.
1 ≤ p[i] ≤ 10^9
Print one integer: the minimum possible difference between the total strengths of the two teams.
| # | input.txt | output.txt |
|---|---|---|
| 1 |
5 3 2 7 4 1 |
1 |