#C11808. Minimum Difference Partition
Minimum Difference Partition
Minimum Difference Partition
You are given n employees, each with an associated skill level. Your task is to divide the employees into two teams such that the absolute difference between the total skill levels of the two teams is minimized.
Formally, let \( \text{skills} = [s_1, s_2, \dots, s_n] \) be the list of skill levels. You need to partition this list into two subsets \( A \) and \( B \) such that the value
[ \text{answer} = \left| \sum_{s \in A} s - \sum_{s \in B} s \right| ]
is minimized. Output the minimum possible absolute difference.
Note: There is no requirement for the two teams to have equal number of employees.
inputFormat
The first line of input contains an integer n representing the number of employees. The second line contains n space-separated integers where each integer represents the skill level of an employee.
For example:
5 1 6 11 5 11
outputFormat
Output a single integer which is the minimum absolute difference between the total skill levels of the two teams.
For example, for the input above, the output should be:
0## sample
5
1 6 11 5 11
0