Pagini recente » Cod sursa (job #486736) | Cod sursa (job #618024) | Citylog | Cod sursa (job #2872197) | Cod sursa (job #2610170)
#include <bits/stdc++.h>
#define DAU ios::sync_with_stdio(false); fin.tie(0); fout.tie(0);
#define PLEC fin.close(); fout.close(); return 0;
using namespace std;
const string problem("lupu");
ifstream fin(problem + ".in");
ofstream fout(problem + ".out");
typedef long long i64;
const int Dim(1e5 + 5);
vector<int> lanitz[Dim];
priority_queue<int> q;
int n, last, x, l, d, a;
i64 res;
int main() {
DAU
fin >> n >> x >> l;
for (int i = 1; i <= n; ++i) {
fin >> d >> a;
if (d <= x) {
last = (x - d) / l + 1;
lanitz[last].emplace_back(a);
}
}
for (int i = Dim - 1; i; --i) {
for (const int& lana : lanitz[i])
q.emplace(lana);
if (!q.empty())
res += q.top(), q.pop();
}
fout << res;
PLEC
}