Pagini recente » Cod sursa (job #518054) | Cod sursa (job #131609) | Cod sursa (job #3244560) | Cod sursa (job #383064) | Cod sursa (job #1052038)
#include <fstream>
#include <algorithm>
#define Nmax 100005
using namespace std;
int N,X,L,len;
struct pereche
{
int timp,lana;
bool operator <(const pereche &A) const
{
return timp<A.timp;
}
};
pereche v[Nmax];
inline void Read()
{
int i,dist,lana,t;
ifstream fin("lupu.in");
fin>>N>>X>>L;
for(i=1;i<=N;++i)
{
fin>>dist>>lana;
t=(X-dist)/L;
++len;
v[len].timp=t; v[len].lana=lana;
}
fin.close();
}
inline void Solve()
{
int poz,maxim,t;
long long sol=0;
sort(v+1,v+len+1);
poz=1;
while(poz<=len)
{
maxim=0; t=v[poz].timp;
if(t>=0)
{
while(poz<=len && v[poz].timp==t)
{
maxim=max(maxim, v[poz].lana);
++poz;
}
sol+=maxim;
}
}
ofstream fout("lupu.out");
fout<<sol<<"\n";
fout.close();
}
int main()
{
Read();
Solve();
return 0;
}