Pagini recente » Cod sursa (job #388455) | Cod sursa (job #1201721) | Cod sursa (job #648701) | Cod sursa (job #3181828) | Cod sursa (job #828173)
Cod sursa(job #828173)
#include<cstdio>
#include<algorithm>
using namespace std;
struct structura
{
int x;int y;
};
structura v[50001];
int 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("%d%d",&n,&m);
for(i=1;i<=n;i++)
scanf("%d%d",&v[i].x,&v[i].y);
sort(v+1,v+n+1,cmp);
scanf("%d%d",&v[1].x,&v[1].y);
indep=1;
for(i=2;i<=n;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("%d",maxim);
return 0;
}