Pagini recente » Cod sursa (job #1219353) | Cod sursa (job #1155403) | Cod sursa (job #2793960) | Cod sursa (job #647683) | Cod sursa (job #1412370)
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
using namespace std;
fstream fin("lupu.in", ios::in);
fstream fout("lupu.out", ios::out);
#define MAXN 100005
int N, max_dist, total, steps, run;
class compare{
public:
bool operator()(pair <int, int> x, pair<int, int> y){
if(x.first != y.first)
return x.first < y.first;
else return x.second < y.second;
}
};
priority_queue <pair<int, int>, vector<pair<int, int> >, compare> heap;
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> node = heap.top();
heap.pop();
if(node.second + steps > max_dist) continue;
total += node.first;
steps += run;
}
fout << total << "\n";
fout.close();
return 0;
}