Cod sursa(job #172619)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 6 aprilie 2008 16:47:43
Problema Orase Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <stdio.h>
# define N 50010
int n,m,max,a,d[N],l[N];
inline int maxim(int x,int y)
{
	if(x>y)	return x;
	return y;
}
void scan()
{
	freopen("orase.in", "r",stdin);
	freopen("orase.out", "w",stdout);
	scanf("%d%d", &m,&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d", &d[i],&l[i]);
}
void solve()
{
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			a=maxim(d[i]-d[j],d[j]-d[i])+l[i]+l[j];
			if(a>max)
				max=a;
		}	
	printf("%d\n", max);
}
int main()
{
	scan();
	solve();
	return 0;
}