It is election time.
The conversion from votes to parliament seats is done using the D'Hondt method with a
- All parties that receive strictly less than
of votes are erased from the list of parties. - The parliament is initially empty i.e. every party has zero seats allocated.
- For each party
, the quotient is calculated, where is the total number of votes received by party , and is the number of seats already allocated to party . - The party with the largest quotient
is allocated one seat. If multiple parties have the same largest quotient, the lower numbered party wins the seat. - Repeat steps
and until the parliament is full.
The votes are being counted and only part of the
Write a program that calculates for each party, among all possible outcomes of the election after all
Input Specification
The first line contains the integers
The second line contains
Output Specification
On the first line output
On the second line output
Scoring
For each test case, the two subtasks (two lines of output) are scored independently.
Solving the first subtask correctly is worth
Solving the second subtask correctly is worth
Sample Input 1
20 4 5
4 3 6 1
Sample Output 1
3 3 3 2
1 0 1 0
Explanation for Sample Output 1
In the first example,
- The quotients are initially
and ; the largest is so party wins a seat. - The quotients are
and ; the largest is so party wins a seat. - The quotients are
and ; the largest is so party wins a seat. - The quotients are
and ; the largest is so party wins a seat. - The quotients are
and ; parties and are tied with quotients and , but party is lower numbered so it wins the last seat.
In this outcome, the numbers of seats won by the parties are
Sample Input 2
100 3 5
30 20 10
Sample Output 2
4 3 3
1 1 0
Comments