Pagini recente » Cod sursa (job #173636) | Cod sursa (job #411069) | Cod sursa (job #1083459) | Cod sursa (job #1978072) | Cod sursa (job #1463398)
#include <iostream>
#include <queue>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin ("lupu.in");
ofstream fout ("lupu.out");
const int wolf = 100000;
int n, x, l;
long long AF;
#define F first
#define S second
vector < pair <int, int> > lup;
priority_queue <int> 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());
int 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;
}