Pagini recente » Cod sursa (job #1504611) | Istoria paginii runda/minune2 | Cod sursa (job #1354310) | Cod sursa (job #1524478) | Cod sursa (job #1155448)
#include <fstream>
using namespace std;
struct pereche
{
int d,l;
};
pereche a[50000];
int main()
{
ifstream in("orase.in");
ofstream out("orase.out");
int n, m, i, distmax = 0, j, s;
in >> m >> n;
for ( i = 1; i <= n; i++ )
{
in >> a[i].d >> a[i].l;
}
for ( i = 1; i < n; i++ )
{
for ( j = i+1; j <= n; j++ )
{
s = a[i].l + a[j].l;
if ( a[i].d > a[j].d )
s = s+ a[i].d - a[j].d;
else
s = s + a[j].d - a[i].d;
if ( s > distmax )
distmax = s;
}
}
out << distmax;
return 0;
}