Pagini recente » Cod sursa (job #221917) | Cod sursa (job #2855648) | Cod sursa (job #2029287) | Cod sursa (job #2128071) | Cod sursa (job #2610167)
#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;
last = (x - d) / l + 1;
lanitz[last].emplace_back(a);
}
for (int i = Dim - 1; i; --i) {
for (const i64& lana : lanitz[i])
q.emplace(lana);
if (!q.empty())
res += q.top(), q.pop();
}
fout << res;
PLEC
}