#C8731. Minimum Skill Difference for Teams
Minimum Skill Difference for Teams
Minimum Skill Difference for Teams
You are given N players with given skill levels. Your task is to split these players into two teams such that the absolute difference between the total skills of the two teams is minimized.
Let \(S\) be the sum of all players' skills. Denote one team's total skill as \(S_1\) and the other as \(S_2\). The goal is to minimize \(|S_1 - S_2|\). This problem can be solved by finding a subset of players whose total skill is as close as possible to \(\frac{S}{2}\).
inputFormat
The input is read from stdin and consists of two lines. The first line contains an integer N representing the number of players. The second line contains N space-separated integers representing the skill levels of the players.
outputFormat
Output a single integer printed to stdout which represents the minimum possible absolute difference between the total skills of the two teams.
## sample5
3 1 4 2 2
0
</p>