Pagini recente » Cod sursa (job #267768) | Cod sursa (job #1282940) | Istoria paginii runda/simulare_lot_seniori_1 | Cod sursa (job #132068) | Cod sursa (job #992074)
Cod sursa(job #992074)
#include <fstream>
#include <algorithm>
#define maxn 100001
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
struct sheep
{
int x,d;
}v[maxn];
int maxx[maxn],n,s,x,l;
inline bool cmp (const sheep &a, const sheep &b)
{
return a.x<b.x;
}
int main()
{
fin>>n>>x>>l;
for (int i=1; i<=n; ++i)
fin>>v[i].d>>v[i].x;
sort (v+1,v+n+1,cmp);
int i=n,t=0;
while (i>0)
{
while (i>0 && v[i].d + t*l > x) --i;
s += v[i].x;
++t;
--i;
}
fout<<s;
}