Pagini recente » Cod sursa (job #2861359) | Cod sursa (job #697491) | Cod sursa (job #2114781) | Cod sursa (job #2749384) | Cod sursa (job #2905616)
#include <fstream>
#include <algorithm>
#include <queue>
using namespace std;
const int dim=1e5+5;
int n,x,l;
long long sol;
struct oaie{
int timp,lana;
}oi[dim];
bool cmp(oaie x,oaie y){
return x.timp<y.timp;
}
priority_queue<int>mxh;
int main(){
ifstream f("lupu.in");
ofstream g("lupu.out");
f>>n>>x>>l;
for(int i=1;i<=n;i++){
int d;
f>>d>>oi[i].lana;
oi[i].timp=(x-d)/l;
}
sort(oi+1,oi+n+1,cmp);
int t=oi[n].timp,p=n;
while(t>=0){
while(p and oi[p].timp>=t)
mxh.push(oi[p--].lana);
if(!mxh.empty())
sol+=mxh.top(),mxh.pop();
t--;
}
g<<sol;
return 0;
}