Pagini recente » Cod sursa (job #1680082) | Cod sursa (job #2568813) | Cod sursa (job #258948) | Cod sursa (job #414648) | Cod sursa (job #1412027)
#include <queue>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
fstream fin("lupu.in", ios::in);
fstream fout("lupu.out", ios::out);
priority_queue < pair<int, int>, vector<pair<int, int>> > heap;
int N, max_dist, run, total, tot_run;
void read()
{
fin >> N >> max_dist >> run;
for (int i = 1, x, y; i <= N; i++)
fin >> x >> y,
heap.push(make_pair(y, x));
fin.close();
}
int main()
{
read();
while (!heap.empty()){
pair<int, int> next = heap.top();
heap.pop();
if (next.second + tot_run > max_dist) continue;
total += next.first;
tot_run += run;
}
fout << total;
fout.close();
return 0;
}