CF457C.Elections
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in the city you know whom he will vote for, and how much it will cost to bribe that person to vote for you instead of whomever he wants to vote for right now. You are curious, what is the smallest amount of money you need to spend on bribing to win the elections. To win elections you need to have strictly more votes than any other candidate.
输入格式
First line contains one integer n ( 1<=n<=105 ) — number of voters in the city. Each of the next n lines describes one voter and contains two integers ai and bi ( 0<=ai<=105; 0<=bi<=104 ) — number of the candidate that voter is going to vote for and amount of money you need to pay him to change his mind. You are the candidate 0 (so if a voter wants to vote for you, ai is equal to zero, in which case bi will also be equal to zero).
输出格式
Print one integer — smallest amount of money you need to spend to win the elections.
输入输出样例
输入#1
5 1 2 1 2 1 2 2 1 0 0
输出#1
3
输入#2
4 1 2 1 2 2 1 0 0
输出#2
2
输入#3
1 100000 0
输出#3
0