Pagini recente » Cod sursa (job #738087) | Cod sursa (job #1364545) | Cod sursa (job #2140046) | Cod sursa (job #2153060) | Cod sursa (job #2361642)
#include<bits/stdc++.h>
#define pii pair<long long,long long>
#define x first
#define y second
#define ll long long
using namespace std;
const ll inf=1e9;
pair<int,int> a[100010];
set<pii>S;
ll n,x,l,rs;
int main() {
ifstream cin("lupu.in");
ofstream cout("lupu.out");
cin>>n>>x>>l;
for (int i=1; i<=n; ++i) {
int x,y; cin>>a[i].y>>a[i].x;
S.insert({0,i});
}
sort(a+1,a+1+n, greater<pair<int,int>>());
for (int i=1; i<=n; ++i) {
pii t=a[i];
ll r=(x-t.y)/l+1;
if (r<=0) continue;
auto it=S.upper_bound({0,r});
if (it==S.begin()) continue;
else --it;
if (it->x==inf) continue;
ll y=it->y;
rs+=t.x;
S.erase(it);
}
cout<<rs;
return 0;
}