思路:
没思路,模拟。
果然是要出去打铁的队…
这种破题wa5搞的我信心全无…
不打铁我吃屎!!!
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long LL;
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define mem(a, b) memset(a, b, sizeof(a))
LL avg;
LL r;
LL n;
struct asd{
LL a;
LL b;
}d[100010];
bool cmp(asd x, asd y){
return x.b < y.b;
}
LL sum, temp;
LL num[100010];
void solve(){
cin>>n>>r>>avg;
sum = temp = 0;
sum = avg * n;
for(int i=1;i<=n;i++){
cin>>d[i].a>>d[i].b;
temp = temp + d[i].a;
}
sort(d+1, d+n+1, cmp);
num[0] = 0;
for(int i=1;i<=n;i++)
num[i] = num[i-1] + r - d[i].a;
LL yp = sum - temp;
LL res = 0;
if(yp>0){
int p = 0;
for(int i=1;i<=n;i++){
if(num[i] <= yp){
res = (r - d[i].a) * d[i].b + res;
p = i;
}
}
if(num[p] == yp){
cout<<res<<endl;
return;
}
if(p < n){
yp = yp - num[p];
res = res + d[p+1].b * yp;
cout<<res<<endl;
return;
}
}
cout<<res<<endl;
}
int main()
{
solve();
return 0;
}