The Fairest Cut
Split the multiset into two groups minimizing the absolute difference of their sums. Print that minimum difference.
Input: the first line has N; the second line has N positive integers.
Output: the minimum achievable difference.
Constraints:
- 1 ≤ N ≤ 100
- 1 ≤ ai ≤ 1000
Sample Tests
Input 1
4 1 6 11 5
Output 1
1
Input 2
1 7
Output 2
7
Discussion (opens after you solve — no spoilers before)
No comments yet.