Pagini recente » Cod sursa (job #337345) | Cod sursa (job #1290925) | Profil usureluflorian | Cod sursa (job #576472) | Cod sursa (job #2076850)
#include <fstream>
#include <queue>
#define f first
#define s second
using namespace std;
ifstream F("lupu.in");
ofstream G("lupu.out");
int n, d, L, x, y, l, maxx;
long long ans;
priority_queue<pair<int, int> > pq;
int main()
{
F >> n >> d >> L;
for( int i = 1; i <= n; ++ i )
{
F >> x >> y;
if( x <= d )
pq.push( { x, y } );
}
while( !pq.empty() )
{
maxx = 0;
while( pq.size() && pq.top().f + l + L > d )
{
x = pq.top().f;
maxx = max( maxx, pq.top().s );
pq.pop();
}
ans += maxx;
l += L;
}
G << ans;
return 0;
}