Pagini recente » Cod sursa (job #2365508) | Cod sursa (job #74688) | Cod sursa (job #894917) | Cod sursa (job #2877363) | Cod sursa (job #723864)
Cod sursa(job #723864)
// 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>>m>>n;
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;
tmp=l[i];
l[i]=l[j];
l[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;
}