In the event of technical difficulties with Szkopuł, please contact us via email at szkopul@fri.edu.pl.
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
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, from all the arrangements of the weights, for which the scales keep balance, one should choose that one which contains the heaviest weight possible. In case of many such solutions only one is to be given.
Write a program which:
In the first line of the standard input there is one integer ,
, equal to the number available weights. In each
of the following
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
in total.
In the first line of the standard output you should write two nonnegative
integers and
, 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
integers separated by single
spaces. They should be the weights of the weights from the first set. The third
line should consist of
integers, separated by single spaces, equal
to the weights of the weights from the second set.
For the input data:
4 1 1 2 7
the correct result is:
2 1 1 1 2
Task author: Krzysztof Onak.