Cod sursa(job #828641)
Utilizator | Claudiu Ion cldme | Data | 4 decembrie 2012 07:54:19 |
---|---|---|---|
Problema | Orase | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <stdio.h>
#include <algorithm>
using namespace std;
int const N=50001;
int p;
struct hrt {
int d,l;
};
hrt v[N];
bool cmp(hrt x, hrt y)
{
return x.d < y.d;
}
int main()
{
int m,n,i;
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
scanf("%d%d",&m,&n);
for(i=1;i<=n;i++)
scanf("%d%d",&v[i].d,&v[i].l);
sort(v+1,v+1+n,cmp);
for(i=1;i<=n;i++)
{
if(v[i].d+v[i].l+m>p)
p=v[i].d+v[i].l+m;
}
printf("%d",p);
return 0;
}