A9722 | Vanya and Exams
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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).
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.
In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted