Pagini recente » Cod sursa (job #3123984) | Cod sursa (job #19786) | Cod sursa (job #1497352) | Cod sursa (job #2040976) | Cod sursa (job #2076836)
#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;
pq.push( { x, y } );
}
while( !pq.empty() )
{
maxx = 0;
while( pq.size() && pq.top().f + l + L > d )
{
maxx = max( maxx, pq.top().s );
pq.pop();
}
ans += maxx;
l += L;
}
G << ans;
return 0;
}