Baltic Olympiad in Informatics: 2008 Day 2, Problem 1
The citizens of Byteland have recently been voting in the parliamentary elections. Now, when the results have been published, the parties have to decide on a coalition to form the government.
Each party received a certain number of seats in the parliament. The coalition must be a subset of the parties such that together they have strictly more than half of all the seats in the parliament. It is desirable for the coalition to have as many seats as possible, to ensure they can still pass their proposed laws even if a few of their members are absent from a parliament session.
A coalition is called redundant if one of its parties can be removed with the remaining ones still having more than half of the seats in the parliament. Of course, such a removable party would effectively have no power — the other members of the coalition would be able to force the laws regardless of its opinion.
Write a program that finds a non-redundant coalition that has the maximal possible number of seats in the parliament.
Constraints
Subtask 1 [40%]
Subtask 2 [60%]
No additional constraints.
Input Specification
The first line of the standard input contains one integer
Output Specification
The first line of output should contain one integer
The second line should contain
If there are several non-redundant coalitions with the maximal number of seats, you may output any of them. The member parties can be listed in any order.
Sample Input
4
1 3 2 4
Sample Output
2
2 4
Comments