Subset

Time Limit
30s
Memory Limit
65536KB
Judge Program
Standard
Ratio(Solve/Submit)
0.00%(0/0)
Description:

Given a list of N integers with absolute values no larger than 1015, find a non empty subset of these numbers which minimizes the absolute value of the sum of its elements. In case there are multiple subsets, choose the one with fewer elements.

Input:

The input contains multiple data sets, the first line of each data set contains N <= 35, the number of elements, the next line contains N numbers no larger than 1015 in absolute value and separated by a single space. The input is terminated with N = 0

Output:

For each data set in the input print two integers, the minimum absolute sum and the number of elements in the optimal subset.

Sample Input:
1
10
3
20 100 -100
0
Sample Output:
10 1
0 2

Submit