Pagini recente » Cod sursa (job #1543884) | Cod sursa (job #1635007) | Cod sursa (job #138146) | Cod sursa (job #2109986) | Cod sursa (job #3267260)
#include <bits/stdc++.h>
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define tpl tuple<int, int, int>
#define piv pair<int, vector<int>>
#define eb emplace_back
#define oo INT_MAX / 2
#define OO LLONG_MAX / 2
using namespace std;
const string fn("lupu");
ifstream in(fn + ".in");
ofstream out(fn + ".out");
#define cin in
#define cout out
int n,x,l;
priority_queue<pii> pq;
void solve()
{
cin>>n>>x>>l;
for(int i=1;i<=n;i++)
{
int d,a;
cin>>d>>a;
int timer=0;
int r=x-d;
timer=r/l;
pq.emplace(a,timer);
}
int timer=0,ans=0;
while(!pq.empty())
{
int w,t;
tie(w,t)=pq.top();
pq.pop();
if(timer<=t)
{
ans+=w;
timer++;
}
}
cout<<ans;
}
signed main()
{
int q = 1;
/// cin >> q;
while (q--)
solve();
return 0;
}