最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

CodeforcesRound#280(Div.2)C_html/css

来源:懂视网 责编:小采 时间:2020-11-27 15:59:07
文档

CodeforcesRound#280(Div.2)C_html/css

CodeforcesRound#280(Div.2)C_html/css_WEB-ITnose:题目: C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n ex
推荐度:
导读CodeforcesRound#280(Div.2)C_html/css_WEB-ITnose:题目: C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n ex

题目:

C. Vanya and Exams

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.

What is the minimum number of essays that Vanya needs to write to get scholarship?

Input

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).

Output

In the first line print the minimum number of essays.

Sample test(s)

input

5 5 45 24 73 13 22 5

output

input

2 5 45 25 2

output

Note

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.


分析:贪心,优先bi最小的。然后注意下n*avg这里会爆LL就好了。

#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define MIN(a, b) ((a) < (b) ? (a) : (b))#define MAX(a, b) ((a) > (b) ? (a) : (b))#define F(i, n) for(int (i)=0;(i)<(n);++(i))#define REP(i, s, t) for(int (i)=(s);(i)<=(t);++(i))#define UREP(i, s, t) for(int (i)=(s);(i)>=(t);--(i))#define REPOK(i, s, t, o) for(int (i)=(s);(i)<=(t) && (o);++(i))#define MEM0(addr) memset((addr), 0, sizeof((addr)))#define PI 3.1415926535897932384626433832795#define HALF_PI 1.5707963267948966192313216916398#define MAXN 100000#define MAXM 10000#define MOD 1000000007typedef long long LL;const double maxdouble = numeric_limits::max();const double eps = 1e-10;const int INF = 0x7FFFFFFF;typedef long long LL;LL n, r, avg;struct node{ LL a, b;};int cmp(node x,node y){ return x.b> n >> r >> avg; vector v; LL tma, tmb, sum = 0; REP(i, 0, n-1) { cin >> tma >> tmb; sum += tma; v.push_back((node) { tma, tmb }); } sort(v.begin(), v.end(), cmp); LL rest = avg*n-sum; if (rest <= 0) { cout << 0; return 0; } LL ans = 0; for (int i=0; i= can) { ans += v[i].b * can; rest -= can; } else { ans += v[i].b * rest; rest = 0; } } cout< 




声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

CodeforcesRound#280(Div.2)C_html/css

CodeforcesRound#280(Div.2)C_html/css_WEB-ITnose:题目: C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n ex
推荐度:
标签: html css div
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top