bzoj#P1181. [CROATIAN2009] IZBROI 选举
[CROATIAN2009] IZBROI 选举
题目描述
在一个地区的选举中,共有 个人参加了投票,每一票只可能投给 个政党中的一个。当地的议会共有 个席位。不妨将 个政党编号为 到 ,并且设编号为 的政党最终的得票为 ,则议会中的席位按如下规则分配:
- 将得票数小于总选票的 的政党剔除;
- 初始时议会为空,每个政党都只有 个席位;
- 对于每个政党 ,计算一个参数 , 为政党 的最终得票, 为政党 当前已经在议会拥有的席位;
- 给 最大的政党分配一个席位,如果有多个政党的 相同,则将席位分给其中编号最小的政党;
- 重复 和 ,直到议会已满。
由于计票还没有结束,现在我们只知道一部分选票的投票结果。给出 以及每个政党当前的得票,请你计算每个政党最多以及最少能赢得多少个席位。
20 4 5
4 3 6 1
3 3 3 2
1 0 1 0
提示
14 votes have been tallied and 6 are yet to be counted.
To illustrate one possible outcome, suppose that the first party receives 2 of those 6 votes, the second none, the third 1 vote and the fourth 3 votes. The parties' totals are 6, 3, 7 and 4 votes.
All parties exceeded the 5% threshold. Seats are allocated as follows:
- The quotients are initially 6/1, 3/1, 7/1 and 4/1; the largest is 7/1 so party 3 wins a seat.
- The quotients are 6/1, 3/1, 7/2 and 4/1; the largest is 6/1 so party 1 wins a seat.
- The quotients are 6/2, 3/1, 7/2 and 4/1; the largest is 4/1 so party 4 wins a seat.
- The quotients are 6/2, 3/1, 7/2 and 4/2; the largest is 7/2 so party 3 wins a seat.
- The quotients are 6/2, 3/1, 7/3 and 4/2; parties 1 and 2 are tied with quotients 6/2 and 3/1, but party 1 is lower numbered so it wins the last seat.
In this outcome, the numbers of seats won by the parties are 2, 0, 2 and 1. Since it is possible for the second party not to win any seats, the second number on the second line of output is zero.
数据规模与约定
对于 的数据,$1 \le v \le 1\times 10^7、 1 \le n \le 100、 1 \le m \le 200$。