Cod sursa(job #1412027)

Utilizator theprdvtheprdv theprdv Data 1 aprilie 2015 06:56:23
Problema Lupul Urias si Rau Scor 8
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#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;
}