Pagini recente » Cod sursa (job #1684510) | Cod sursa (job #2699676) | Cod sursa (job #169389) | Cod sursa (job #1852982) | Cod sursa (job #2034062)
#include<fstream>
#include<queue>
#include<algorithm>
using namespace std;
ifstream f("lupu.in");
ofstream g("lupu.out");
struct oaie {
int dist;
int puf;
} a[100002];
/*bool cmp(oaie a, oaie b)
{
if(a.dist==b.dist)
return a.puf>=b.puf;
return a.dist>=b.dist;
}*/
priority_queue <int, vector<int> > heap;
int n, d, l, k, s, i, t[100002], tmax;
int main ()
{
f>>n>>d>>l;
for(i=1;i<=n;i++)
{
f>>a[i].dist>>a[i].puf;
t[i]=(d-a[i].dist)/l+1;
if(t[i]>tmax)
tmax=t[i];
if(t[i]<0)
t[i]=2147483648;
}
//sort(a+1,a+n+1, cmp);
for(i=tmax;i>0;i--)
{
for(int ii=1;ii<=n;ii++)
if(t[ii]==i)
heap.push(a[ii].puf);
s+=heap.top();
heap.pop();
}
g<<s;
return 0;
}