Pagini recente » Cod sursa (job #1038444) | Cod sursa (job #1583872) | Cod sursa (job #1930048) | Cod sursa (job #3219200) | Cod sursa (job #1844810)
#include<fstream>
#include<algorithm>
#define Nmax 100005
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
struct oita{
int lana,coef;
};
int X, L, N;
oita v[Nmax];
long long totalLana;
bool cmp(oita x, oita y){
if(x.coef<y.coef || x.coef==y.coef && x.lana>y.lana)
return true;
return false;
}
int main(){
int d, cant,k=0,cmax=0,cf;
fin>>N>>X>>L;
for(int i=1;i<=N;i++){
fin>>d>>cant;
if(d<=X){
k++;
v[k].lana=cant;
v[k].coef=(X-d)/L;
cmax=max(cmax,v[k].coef);
}
}
sort(v+1,v+N+1,cmp);
cf=0;
for(int i=1;i<=k;i++)
if(v[i].coef>=cf){
totalLana+=v[i].lana;
cf++;
}
fout<<totalLana;
return 0;
}