Pagini recente » Cod sursa (job #1497722) | Cod sursa (job #3244426) | Cod sursa (job #2602544) | Cod sursa (job #2618931) | Cod sursa (job #806588)
Cod sursa(job #806588)
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> > V;
int n,m,l,x,y,SOL[100010],solcnt,L,cnt,i;
long long SOLUTIE;
int main()
{
freopen("lupu.in","r",stdin);
freopen("lupu.out","w",stdout);
scanf("%d%d%d",&n,&m,&l);
for(i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
V.push_back(make_pair(x,y));
}
sort(V.rbegin(),V.rend());
L=0;cnt=1;
for(vector<pair<int,int> >::iterator it=V.begin();it!=V.end();it++)
{
x=(*it).first;
y=(*it).second;
if(x+L>m)continue;
if(x+L<=m&&x+L+l>m)
{
SOL[++solcnt]=-y;
continue;
}
sort(SOL+1,SOL+solcnt+1);
solcnt=cnt;
++cnt;
--it;
L+=l;
}
for(i=1;i<=cnt;i++)
SOLUTIE+=(long long)(-SOL[i]);
printf("%lld\n",SOLUTIE);
return 0;
}