Cod sursa(job #2076836)
| Utilizator | Data | 27 noiembrie 2017 11:02:08 | |
|---|---|---|---|
| Problema | Lupul Urias si Rau | Scor | 16 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#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;
}
