Cod sursa(job #495672)

Utilizator mattapoMatei Apolzan mattapo Data 26 octombrie 2010 15:04:58
Problema Orase Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<stdio.h>
#include<algorithm>

using namespace std;

const int N = 1<<16;

struct oras
{
	int x,y;
};

int n;
oras v[N];

bool cmp(oras p,oras q)
{
	return p.x < q.x;
}

int main ()
{
	int n,m,dist,max=0,i,j;
	freopen("orase.in","r",stdin);
	freopen("orase.out","w",stdout);
	scanf("%d",&m);
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&v[i].x);
		scanf("%d",&v[i].y);
	}
	sort(&v[1],&v[1+n],cmp);
	for  (i=1;i<=n;i++)
	{
		for (j=i+1;j<=n;j++)
		{
			dist=v[j].x-v[i].x+v[j].y+v[i].y; 
			if (dist>max)
				max=dist;
		}
	}
	printf("%d",max);
	return 0;
}