#P7743. D'Hondt Method Representative Allocation

    ID: 20930 Type: Default 1000ms 256MiB

D'Hondt Method Representative Allocation

D'Hondt Method Representative Allocation

In a certain electoral district there are (x) voters and (n) political parties participating in a parliamentary election. The election uses the D'Hondt allocation method with the following procedure:

1. Only parties that receive at least (5%) of the total voters (i.e. having at least (0.05 \times x) votes) are considered.

2. For each qualified party with (v) votes, compute 14 scores defined as (\frac{v}{d}) for (d = 1,2,\dots,14). These scores are real numbers and all scores across all parties are guaranteed to be distinct.

3. All the computed scores are sorted in descending order. The top 14 scores are selected, and each selected score awards one representative to the corresponding party.

Your task is to write a program that, given the total number of voters and the vote counts for each party, determines for every party that meets the threshold the number of representatives it obtains, in the order they appear in the input.

inputFormat

The input consists of two lines:

- The first line contains two integers (x) and (n), where (x) ((1 \le x \le 10^9)) is the total number of voters and (n) ((1 \le n \le 100)) is the number of political parties.

- The second line contains (n) integers. The (i)-th integer represents the number of votes received by the (i)-th party. It is guaranteed that the parties’ vote counts and the divisions produce scores that are all distinct.

outputFormat

Output a single line containing the number of representatives allocated to each qualified party (i.e. those with at least (5%) of (x) votes), in the order of their appearance in the input, separated by a single space. Exactly 14 seats in total are allocated.

sample

100000 3
6001 3000 5000
8 6