CF492C.Vanya and Exams

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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?

万尼亚希望通过 nn 门考试并获得学业奖学金。当所有考试的平均分至少为 avg\text{avg} 时,他便可获得奖学金。单科考试成绩最高不得超过 rr。万尼亚已通过所有考试,并在第 ii 门考试中取得了 aia_i 分。要将第 ii 门考试的成绩提高 11 分,万尼亚必须撰写 bib_i 篇论文。他可以多次提升同一门考试的成绩。

万尼亚为获得奖学金所需撰写的论文数最少是多少?

输入格式

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 a__i and b__i (1 ≤ a__i ≤ r, 1 ≤ b__i ≤ 106).

第一行包含三个整数 nn、rr、avg\text{avg}(1≤n≤1051 \leq n \leq 10^5,1≤r≤1091 \leq r \leq 10^9,1≤avg≤min⁡(r, 106)1 \leq \text{avg} \leq \min(r,\,10^6)),分别表示考试科目的数量、最高分以及所需的平均分。

接下来的 nn 行中,每行包含两个用空格分隔的整数 aia_i 和 bib_i(1≤ai≤r1 \leq a_i \leq r,1≤bi≤1061 \leq b_i \leq 10^6)。

输出格式

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.

在第一个样例中,万尼亚可以为第 3 次考试写 2 篇论文,使他的成绩提高 2 分;并为第 4 次考试写 2 篇论文,使他的成绩提高 1 分。

在第二个样例中,万尼亚无需撰写任何论文,因为他的平均分已经高于平均分。

输入解题思路,AI测评打分。不知道怎么写?

首页