Pagini recente » Cod sursa (job #1589944) | Cod sursa (job #794364) | Cod sursa (job #1371838) | Cod sursa (job #1652964) | Cod sursa (job #828175)
Cod sursa(job #828175)
#include<cstdio>
#include<algorithm>
using namespace std;
struct structura
{
int x;int y;
};
structura v[50001];
long long i,indep,maxim,n,m;
bool cmp(structura a,structura b)
{
return a.x<b.x;
}
int main()
{
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
scanf("%lld%lld",&n,&m);
for(i=1;i<=m;i++)
scanf("%lld%lld",&v[i].x,&v[i].y);
sort(v+1,v+m+1,cmp);
scanf("%d%d",&v[1].x,&v[1].y);
indep=1;
for(i=2;i<=m;i++)
{
if(v[i].x-v[indep].x+v[i].y+v[indep].y>maxim)
maxim=v[i].x-v[indep].x+v[i].y+v[indep].y;
if(v[i].x-v[indep].x<v[i].y)
indep=i;
}
printf("%lld",maxim);
return 0;
}