302373: CF457C. Elections
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Elections
题意翻译
``` 题面: 你打算在俄罗斯的一个小城市竞选州长,你对投票人的投票意向进行了调查。现在,对于城市中每一个参与投票的人,你都知道他们会投谁的票,也知道贿赂那个人投票给你需要花多少钱(我从未见过有如此厚颜无耻之人)。为了赢得选举,你的得票数必须比其他参与竞选的人多。那么你至少要破费多少钱才能赢得竞选呢? 输入: 第一行:参与投票的人数 $n$ . 接下来 $n$ 行,每行两个数 $a_i,b_i$ .其中 $a_i$ 表示这位投票人想投给的竞选者编号(你自己的编号为 $0$ ); $b_i$ 表示贿赂他投票给你需要的金额. 输出: 赢得选举的最小金额 数据范围: $(1<=n<=10^5)$ $(0<=a_i<=10^5;0<=b_i<=10^4)$ ```题目描述
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<=10^{5} $ ) — number of voters in the city. Each of the next $ n $ lines describes one voter and contains two integers $ a_{i} $ and $ b_{i} $ ( $ 0<=a_{i}<=10^{5}; 0<=b_{i}<=10^{4} $ ) — 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, $ a_{i} $ is equal to zero, in which case $ b_{i} $ 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