Pagini recente » Cod sursa (job #2617962) | Cod sursa (job #2741320) | Cod sursa (job #302018) | Cod sursa (job #742428) | Cod sursa (job #2286689)
#include <bits/stdc++.h>
using namespace std;
#if 1
#define pv(x) cout<<#x<<" = "<<(x)<<"; ";cout.flush()
#define pn cout<<endl
#else
#define pv(x)
#define pn
#endif
#ifdef INFOARENA
ifstream in("lupu.in");
ofstream out("lupu.out");
#else
#define in cin
#define out cout
#endif
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pld = pair<ld, ld>;
#define pb push_back
const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862;
const int inf_int = 1e9 + 5;
const ll inf_ll = 1e18 + 5;
const int NMax = 1e2 + 5;
const int dx[] = {-1,0,0,+1}, dy[] = {0,-1,+1,0};
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
ll N,X,L;
in >> N >> X >> L;
vector<pll> v(N);
for (auto& p : v) {
in >> p.first >> p.second;
}
sort(v.begin(), v.end());
multiset<ll> wool;
int pos = 0;
ll ans = 0;
for (ll i = N-1; i >= 0; --i) {
while (pos < N && v[pos].first + i * L <= X) {
wool.insert(v[pos].second);
pos += 1;
}
if (wool.size()) {
ans += *(--wool.end());
wool.erase(--wool.end());
}
}
out << ans << '\n';
return 0;
}