#C3281. Partitioning Teams
Partitioning Teams
Partitioning Teams
You are given n participants along with their respective skill levels. Your task is to split these participants into two teams such that the absolute difference between the total skill levels of the two teams is minimized.
Formally, given an integer \( n \) and a list of integers \( a_1, a_2, \dots, a_n \) representing the skill levels, partition the list into two subsets such that the absolute difference between the sum of the two subsets is as small as possible. This problem is a variation of the classic partition problem.
Example: For n = 6
and skill_levels = [3, 1, 4, 2, 2, 1]
, one optimal partition gives an absolute difference of 1.
inputFormat
The input is read from standard input and has the following format:
- The first line contains a single integer \( n \), representing the number of participants.
- The second line contains \( n \) space-separated integers representing the skill levels of the participants.
outputFormat
Output to standard output a single integer, which is the minimal possible absolute difference between the total skill levels of the two teams.
## sample6
3 1 4 2 2 1
1