Pagini recente » Cod sursa (job #3212507) | Cod sursa (job #1554756) | Cod sursa (job #2464483) | Cod sursa (job #30209) | Cod sursa (job #3243677)
#include <iostream>
#include <queue>
#include <fstream>
#include <utility>
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
pair<unsigned int, unsigned int> H;
priority_queue<pair<unsigned int, unsigned int>, vector<pair<unsigned int,unsigned int> > > pq;
bool operator<(const pair<unsigned int, unsigned int>& a, const pair<unsigned int, unsigned int>& b){
if (a.first < b.first) return true;
if (a.first > b.first) return false;
if(a.second < b.second) return true;
return false;
}
int main(){
unsigned int N, X, L;
in >> N >> X >> L;
for(int i = 0; i<N; i++){
unsigned int D, F;
in >> D >> F;
H = make_pair(F, D);
pq.push(H);
}
long long total = 0;
unsigned int step = 0;
while(pq.empty() == false){
//cout << pq.top().first << " " << pq.top().second << endl;
unsigned int add = L * step;
if(pq.top().second + add <= X){
total+=pq.top().first;
step++;
}
pq.pop();
}
out << total;
}