Pagini recente » Cod sursa (job #2851403) | Cod sursa (job #1551603) | Cod sursa (job #3267502) | Cod sursa (job #2727011) | Cod sursa (job #3267389)
#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,multiset<int>> M;
void solve()
{
cin>>N>>X>>L;
for(int i=1;i<=N;i++)
{
int d,a;
cin>>d>>a;
int r=(X-d)/L;
M[r].insert(-a);
///cout<<a<<' '<<d<<' '<<r<<'\n';
}
int timer=0,ans=0;
for(auto x: M)
{
auto it=x.second.begin();
while(timer<=x.first and it!=x.second.end())
{
ans+=-*it;
it++;
timer++;
}
}
cout<<ans;
}
signed main()
{
int q = 1;
/// cin >> q;
while (q--)
solve();
return 0;
}