302547: CF492C. Vanya and Exams

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Vanya and Exams

题意翻译

有个有n门课程,每门课程他最多获得r学分,他只要所有课程的平均学分等于avg,他就可以获得奖学每门课程,他已经获得了ai学分,剩下的每个学分,都需要写bi篇论才能得到,然后问你,最少要写多少论文才能 获得奖学金 1<=n<=10^5;1<=avg<=10^6;1<=r<=10^9 感谢@凉凉 提供的翻译

题目描述

Vanya wants to pass $ n $ exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least $ avg $ . The exam grade cannot exceed $ r $ . Vanya has passed the exams and got grade $ a_{i} $ for the $ i $ -th exam. To increase the grade for the $ i $ -th exam by 1 point, Vanya must write $ b_{i} $ essays. He can raise the exam grade multiple times. What is the minimum number of essays that Vanya needs to write to get scholarship?

输入输出格式

输入格式


The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively. Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).

输出格式


In the first line print the minimum number of essays.

输入输出样例

输入样例 #1

5 5 4
5 2
4 7
3 1
3 2
2 5

输出样例 #1

4

输入样例 #2

2 5 4
5 2
5 2

输出样例 #2

0

说明

In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point. In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.

Input

题意翻译

Venya 有 $n$ 门课程,每门课程他最多获得 $r$ 学分,他只要所有课程的平均学分大于等于 $avg$,他就可以获得奖学金。 目前对于第 $i$ 门课程,他已经获得了 $a_i$ 学分,剩下的每个学分,都需要写 $b_i$ 篇论文才能得到。请问 Venya 最少要写多少论文才能获得奖学金? 数据保证 $1\le n\le 10^5,1\le avg\le 10^6,1\le r\le 10^9$。

加入题单

上一题 下一题 算法标签: