Pagini recente » Cod sursa (job #219492) | Cod sursa (job #234353) | Cod sursa (job #3245459) | Cod sursa (job #1351599) | Cod sursa (job #2647423)
#include <bits/stdc++.h>
using namespace std;
int main () {
freopen("lupu.in", "r", stdin);
freopen("lupu.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, x, l;
cin >> n >> x >> l;
vector <pair <int, int>> v(n);
for (auto &it: v)
cin >> it.first >> it.second;
sort(v.begin(), v.end());
priority_queue <int> PQ;
long long ans = 0;
int i = 0, d;
for (d = 0; d <= x; d += l) {
while (i < n && v[i].first <= d)
PQ.push(v[i++].second);
if (!PQ.empty()) {
ans += PQ.top();
PQ.pop();
}
}
cout << ans;
return 0;
}