Nu exista pagina, dar poti sa o creezi ...
Cod sursa(job #3241617)
Utilizator | Data | 1 septembrie 2024 14:45:57 | |
---|---|---|---|
Problema | Lupul Urias si Rau | Scor | 88 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.78 kb |
#include <fstream>
#include <queue>
#include <algorithm>
using namespace std;
ifstream f("lupu.in");
ofstream g("lupu.out");
const int nmax = 100005;
struct oaie{
long long lana, timp;
bool operator < (const oaie o){
return timp < o.timp;
}
};
oaie oi[nmax];
priority_queue<long long> q;
long long sol;
long long n, l, x;
int main(){
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);
int p = n;
int t = oi[n].timp;
while(t >= 0){
while(p > 0 && oi[p].timp >= t){
q.push(oi[p].lana);
p--;
}
sol += q.top();
q.pop();
t--;
}
g << sol;
}