Pagini recente » Cod sursa (job #1182215) | Cod sursa (job #1557097) | Cod sursa (job #1294818) | Profil BirtasAndrei | Cod sursa (job #1858239)
#include <bits/stdc++.h>
using namespace std;
ifstream f("lupu.in");
ofstream g("lupu.out");
const int nmax=100005;
struct oaie {int val,disti,steps;};
oaie a[nmax];
int n,dmax,salt,maxstep=-1,raspuns;
priority_queue <int> cod;
bool cmp (oaie A , oaie B)
{
return A.steps>B.steps;
}
int main()
{
int i,k;
f>>n>>dmax>>salt;
for (i=1;i<=n;i++)
{
f>>a[i].disti>>a[i].val;
a[i].steps=(dmax-a[i].disti)/salt;
maxstep=max(maxstep,a[i].steps);
}
sort (a+1,a+n+1,cmp);
i=1;
for (k=maxstep;k>=0;k--)
{
while (a[i].steps==k)
{
cod.push(a[i].val);
i++;
}
if (!cod.empty())
{
g<<cod.top()<<'\n';
raspuns+=cod.top();
cod.pop();
}
}
g<<raspuns;
return 0;
}