Pagini recente » Cod sursa (job #1330458) | Cod sursa (job #3126985) | Statistici Alin Nereid (Nereid) | Profil palecsandru | Cod sursa (job #2742212)
#include <fstream>
#include <algorithm>
#include <queue>
using namespace std;
ifstream fin( "lupu.in" );
ofstream fout( "lupu.out" );
const int NMAX = 1e5;
struct lol{
int timp, lana;
bool operator < ( const lol &shit ) const {
return timp < shit.timp;
}
};
lol v[NMAX + 1];
priority_queue <int> pq;
int main() {
int n, x, l, i, m, a, d, lana;
long long ans;
fin >> n >> x >> l;
m = 0;
for( i = 1; i <= n; ++i ){
fin >> d >> lana;
if( d <= x )
v[++m] = {(x - d) / l, lana};
}
sort( v + 1, v + m + 1 );
i = m; ans = 0; a = n - 1;
while( a >= 0 ){
while( i >= 1 && a == v[i].timp )
pq.push(v[i--].lana);
a--;
if( !pq.empty() ){
ans += pq.top();
pq.pop();
}
}
fout << ans;
return 0;
}