As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — nn and mm respectively. For each voter you know the party he is going to vote for. However, he can easily change his vote given a certain amount of money. In particular, if you give ii-th voter cicibytecoins you can ask him to vote for any other party you choose.
The United Party of Berland has decided to perform a statistical study — you need to calculate the minimum number of bytecoins the Party needs to spend to ensure its victory. In order for a party to win the elections, it needs to receive strictly more votes than any other party.
Input
The first line of input contains two integers nn and mm (1≤n,m≤30001≤n,

这是一道关于选举策略的问题,目标是计算确保1号候选人赢得选举所需的最小花费。给定每个选民的首选政党及改变投票的代价,需要找出使1号候选人获得最多票数的最小成本。
最低0.47元/天 解锁文章
535

被折叠的 条评论
为什么被折叠?



