Pagini recente » Cod sursa (job #2940338) | Cod sursa (job #499815) | Cod sursa (job #695301) | Cod sursa (job #709177) | Cod sursa (job #1463402)
#include <iostream>
#include <queue>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin ("lupu.in");
ofstream fout ("lupu.out");
const int wolf = 100000;
long long n, x, l, AF;
#define F first
#define S second
vector < pair <long long, long long> > lup;
priority_queue <long long> RP;
//auto Comp = [](const pair <int, int> &a, const pair <int, int> &b) {
// return (a.F > b.F);
//};
int main(){
fin >> n >> x >> l;
lup.resize(n);
for (int i = 0; i < n; i++)
fin >> lup[i].F >> lup[i].S;
sort(lup.begin(), lup.end());
long long T = (x - lup[0].F) / l;
int p = 0;
//fout << (1 << 31) - 1 << "\n" ;
for (; T >= 0; -- T ) {
while (p < n and (x - lup[p].F) / l == T )
RP.push(lup[p ++ ].S);
if (!RP.empty())
AF += RP.top(), RP.pop();
}
fout << AF;
return 0;
}