Pagini recente » Profil bubblegumix | Cod sursa (job #1530072) | Cod sursa (job #260082) | Cod sursa (job #576566) | Cod sursa (job #425470)
Cod sursa(job #425470)
//#include "stdafx.h"
#include <set>
#include <algorithm>
#define NMAX 100100
using namespace std;
multiset < long > heap;
long i,j,n,m,k,l,a,b,c;
long long s;
struct kkt
{
long X,Y,Z;
} x[NMAX];
long cmpf(kkt a , kkt b)
{
return (a.Z<b.Z);
}
int main()
{
freopen("lupu.in","r",stdin);
freopen("lupu.out","w",stdout);
scanf("%ld%ld%ld",&n,&k,&l);
for (i=1;i<=n;i++)
{
scanf("%ld%d",&x[i].X,&x[i].Y);
x[i].Z=(k-x[i].X)/l+1;
if (k<x[i].X)
x[i].Z=0;
}
sort(x+1,x+n+1,cmpf);
m=x[n].Z;
j=n;
for (i=m;i>=1;i--)
{
while (x[j].Z==i&&j>=1)
{
heap.insert(-x[j].Y);
j--;
}
if (heap.begin()!=heap.end())
{
s-=*heap.begin();
heap.erase(heap.begin());
}
}
printf("%lld\n",s);
return 0;
}