Pagini recente » Cod sursa (job #1154732) | Cod sursa (job #1828278) | Cod sursa (job #654094) | Cod sursa (job #2712825) | Cod sursa (job #1396814)
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
const int NMAX=100005;
int n,x,l;
PII a[NMAX];
long long sol;
inline bool cmp(const PII A,const PII B)
{
if (A.fi==B.fi) return A.se<B.se;
return A.fi<B.fi;
}
int main()
{
int i,aux,mx,cnt=0;
bool ok=0;
fin>>n>>x>>l;
for (i=1;i<=n;i++) fin>>a[i].se>>a[i].fi;
sort(a+1,a+n+1,cmp);
for (i=n;i>=1;i--)
{
if (x<a[i].se) aux=0;
else aux=((x-a[i].se)/l)+1;
if (aux>0)
{
if (ok==0) {mx=aux;ok=cnt=1;sol+=a[i].fi;}
else if (aux>mx || cnt<mx)
{
sol+=a[i].fi;
mx=max(mx,aux);
cnt++;
}
}
}
fout<<sol<<"\n";
return 0;
}