1364. Balance

单点时限: 2.0 sec

内存限制: 256 MB

We have a balance at our disposal. The scales are in balance if and only if both pans are empty or the weights on each pan weigh the same in total. In the given set of weights one should find such two disjoint subsets that, after putting all the weights of one on one pan and all the weights of the other on the other pan, the scales are in balance. Moreover, we require to put on the scales the heaviest weight possible.

Task

Write a program which:

1.reads the weights of the available weights,

2.selects two disjoint sets of the weights meeting the conditions of the task,

3.writes the result.

输入格式

In the first line there is one integer n, 2<=n<=1 000, equal to the number available weights. In each of the following n lines there is one positive integer being the weight of one weight from the set of available weights. You may assume that all the weights weigh at most 50 000 in total.

输出格式

In the first line you should write two nonnegative integers p and q, separated by a single space, and denoting the numbers of weights in the first and the second set, respectively. In the second line there should be p integers separated by single spaces. They should be the weights of the weights from the first set. The third line should consist of q integers, separated by single spaces, equal to the weights of the weights from the second set.

样例

Input
4
1
1
2
7
Output
2 1
1 1
2

1 人解决,2 人已尝试。

1 份提交通过,共有 18 份提交。

9.9 EMB 奖励。

创建: 17 年,3 月前.

修改: 7 年,2 月前.

最后提交: 1 年,4 月前.

来源: POI

题目标签