Pagini recente » Cod sursa (job #2846926) | Cod sursa (job #2054357) | Cod sursa (job #1281475) | Cod sursa (job #3005705) | Cod sursa (job #1132121)
#include<algorithm>
#include<cstdio>
using namespace std;
const int NMAX = 100000+5;
struct Gutuie
{
int height,weight,fruits;
void Set(int h,int w,int f)
{
height=h;
weight=w;
fruits=f;
}
bool operator()(Gutuie A,Gutuie B)
{
if(A.fruits==B.fruits) return A.weight>B.weight;
return A.fruits<B.fruits;
}
};
int N,H,U,NrG;
long long WeG;
Gutuie V[NMAX];
int main()
{
int i,h,w,f;
freopen("gutui.in","r",stdin);
freopen("gutui.out","w",stdout);
scanf("%d%d%d",&N,&H,&U);
for(i=1; i<=N; i++)
{
scanf("%d%d",&h,&w);
if(h>H) f=-1;
else f=(H-h)/U;
V[i].Set(h,w,f);
}
sort(V+1,V+N+1,Gutuie());
for(i=1; i<=N; i++)
if(V[i].fruits>=NrG)
{
NrG++;
WeG+=1LL*V[i].weight;
}
printf("%lld\n",WeG);
return 0;
}