CF457C.Elections
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
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 a__i and b__i (0 ≤ a__i ≤ 105; 0 ≤ b__i ≤ 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, a__i is equal to zero, in which case b__i will also be equal to zero).
第一行包含一个整数 n(1≤n≤105)—— 表示该城市选民的数量。接下来的 n 行每行描述一位选民,包含两个整数 ai 和 bi(0≤ai≤105;0≤bi≤104)—— 分别表示该选民原本打算投票给的候选人编号,以及你为使其改变主意所需支付给他的金额。你是候选人 0(因此若某位选民原本打算投给你,则 ai=0,此时 bi 也必为 0)。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?