Pagini recente » Cod sursa (job #736762) | Cod sursa (job #1420922) | Cod sursa (job #13954) | Cod sursa (job #2039034) | Cod sursa (job #3267377)
#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
class cmp{
public:
bool operator()(pii a,pii b)
{
if(a.first<b.first)
return 1;
if(a.first==b.first and a.second<b.second)
return 1;
return 0;
}
};
int N,X,L;
map<int,set<int>> M;
set<int> s;
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);
s.insert(r);
///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++;
///cout<<x.first<<' '<<timer<<'\n';
timer++;
}
}
cout<<ans;
}
signed main()
{
int q = 1;
/// cin >> q;
while (q--)
solve();
return 0;
}