It is election time. voters attend the election, each casting their vote for one of
political parties.
officials will be elected into the parliament.
The conversion from votes to parliament seats is done using the D'Hondt method with a threshold.
More precisely, suppose that the parties are numbered
through
and that they receive
votes. Parliament seats are allocated as follows:
- 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 votes has been tallied. It is known how many votes
each party has received so far.
Write a program that calculates for each party, among all possible outcomes of the election after all
votes are counted, the largest and smallest number of seats the party wins.
Input Specification
The first line contains the integers ,
and
, the
numbers of votes, parties and seats in the parliament.
The second line contains integers – how many votes (of those that have been counted) each party
got. The sum of these numbers will be at most
.
Output Specification
On the first line output integers separated by spaces – the largest number of seats each party can win.
On the second line output integers separated by spaces – the smallest number of seats each party can win.
Scoring
For each test case, the two subtasks (two lines of output) are scored independently.
Solving the first subtask correctly is worth of points.
Solving the second subtask correctly is worth of points. It is necessary to output exactly
integers
on the first line (even if they are completely wrong) for the second subtask to be graded.
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, votes have been tallied and
are yet to be counted. To illustrate one possible
outcome, suppose that the first party receives
of those
votes, the second none, the third
vote and
the fourth
votes. The parties' totals are
and
votes. All parties exceeded the
threshold.
Seats are allocated as follows:
- 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 and
. Since it is possible for the
second party not to win any seats, the second number on the second line of output is zero.
Sample Input 2
100 3 5
30 20 10
Sample Output 2
4 3 3
1 1 0
Comments