Pagini recente » Cod sursa (job #824908) | Cod sursa (job #474897) | Cod sursa (job #2780459) | Cod sursa (job #3231454) | Cod sursa (job #1956597)
#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;
long long 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;
}