Pagini recente » Cod sursa (job #2961692) | Cod sursa (job #218494) | Cod sursa (job #3221066) | Cod sursa (job #970267) | Cod sursa (job #3267500)
#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;
map<int,priority_queue<int>> M;
void solve()
{
cin>>N>>X>>L;
assert(L==0);
for(int i=1;i<=N;i++)
{
int d,a;
cin>>d>>a;
int r=0;
if(L==0)
r=OO;
else r=(X-d)/L;
M[r].emplace(a);
///cout<<a<<' '<<d<<' '<<r<<'\n';
}
int timer=0,ans=0;
for(auto x: M)
{
auto pq=x.second;
while(timer<=x.first and pq.size())
{
ans+=pq.top();
pq.pop();
timer++;
}
}
cout<<ans;
}
signed main()
{
int q = 1;
/// cin >> q;
while (q--)
solve();
return 0;
}