Mai intai trebuie sa te autentifici.
Cod sursa(job #1003232)
Utilizator | Data | 29 septembrie 2013 23:23:52 | |
---|---|---|---|
Problema | Orase | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.69 kb |
#include<cstdio>
#include<algorithm>
struct oras{
int d;
int l;
}v[50010];
bool cresc(oras x,oras y){
return x.d<y.d;
}
int main(){
int max=0,mult,i,j,q,p,m,n;
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
scanf("%d%d\n",&m,&n);
for(i=1;i<=n;i++){
scanf("%d%d",&v[i].d,&v[i].l);
}
std::sort(&v[1],&v[n+1],cresc);
for(i=1;i<=n;i++){
for(j=n;j>=i;j--){
mult=v[i].l+v[j].l+v[j].d-v[i].d;
if(mult>max){
max=mult;
q=i;
p=j;
}
}
}
printf("%d",v[q].l+v[p].l+v[p].d-v[q].d);
return 0;
}