Cod sursa(job #723860)

Utilizator 5t3fristea stefan 5t3f Data 25 martie 2012 23:19:18
Problema Orase Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
// orase.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include "fstream"
using namespace std;
int main()
{
	ifstream f("orase.in");
	ofstream g("orase.out");
	int n,m,d[50000],l[50000];
	f>>n>>m;
	int i;
	for(i=0;i<n;i++)
		f>>d[i]>>l[i];
	int j;
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
			if(d[i]>d[j])
			{
				int tmp=d[i];
				d[i]=d[j];
				d[j]=tmp;
			}
	int max=0;
	for(i=0;i<n-1;i++)
		for(j=0;j<n;j++)
		{
			int tmp=l[i]+l[j]+d[j]-d[i];
			if(tmp>max)
				max=tmp;
		}
	g<<max;
	return 0;
}