Pagini recente » Cod sursa (job #424888) | Cod sursa (job #1953434) | Cod sursa (job #2085539) | Cod sursa (job #2223090) | Cod sursa (job #723860)
Cod sursa(job #723860)
// 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;
}