Pagini recente » Cod sursa (job #1710389) | Cod sursa (job #1634155) | Cod sursa (job #2319252) | Cod sursa (job #1194954) | Cod sursa (job #2647422)
#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;
int i = 0, d, ans = 0;
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;
}