Cod sursa(job #2069532)
| Utilizator | Data | 18 noiembrie 2017 15:41:26 | |
|---|---|---|---|
| Problema | Lupul Urias si Rau | Scor | 8 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include<fstream>
#include<algorithm>
using namespace std;
int n,x,l,i,t,X;
long long s;
struct oaie{int d,c;};
oaie v[100010];
ifstream f("lupu.in");
ofstream g("lupu.out");
bool comp(oaie a,oaie b)
{
if(a.c>b.c) return 1;
if(a.c==b.c && a.d>b.d) return 1;
return 0;
}
int main()
{
f>>n>>X>>l;
for(i=1;i<=n;i++)
f>>v[i].d>>v[i].c;
sort(v+1,v+n+1,comp);
t=0;
s=0;
for(i=1;i<=n;i++)
{
if(v[i].d+t<=X)
{
s+=v[i].c;
t+=l;
}
}
g<<s;
f.close();
g.close();
return 0;
}
