DWITE Online Computer Programming Contest, February 2011, Problem 3
Being the star attraction of the local carnival, it's your job to come up with new acts for every show. For the next show, you decided that you would give a shot at riding a unicycle while balancing weights on both your hands. To make sure that you don't fall, you want the weights in your hands to balance out as much as possible (i.e. the difference between the sum of the weights in either of your hands must be as small as possible). Given the weights you have, determine the smallest difference in weight between your left and right hands.
The input will contain 5 test cases. The first line contains a number representing the number of weights you have. The next lines each contain a number representing how heavy each weight is.
The output should contain 5 lines, each line representing the minimum difference of weight between your two hands.
Note: the trivial solution of having zero weight in both hands is not acceptable ;)
3 1 10 6 5 9 4 5 7 1
Problem Resource: DWITE