Cod sursa(job #2209668)

Utilizator AgacheGabrielAgache Gabriel AgacheGabriel Data 4 iunie 2018 01:51:32
Problema Orase Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
#include <cmath>
#include <iostream>

using namespace std;

ifstream fin("orase.in");
ofstream fout("orase.out");

struct Punct
{
    int d;
    int l;
};

int distBetw(Punct& A, Punct& B)
{
    ///DE NU UITAT CAZUL IN CARE AU ACEEASI DISTANTA FARA DE CAPATUL STRAZII
    return A.l+B.l+abs(A.d-B.d);
}

Punct puncte[50010];
int M,N,best;



int main()
{
    fin>>M>>N;
    for (int i=1;i<=N;i++)
        fin>>puncte[i].d>>puncte[i].l;
    for (int i=1;i<=N;i++)
        for (int j=i+1;j<=N;j++)
            if (best<distBetw(puncte[i],puncte[j])) best = distBetw(puncte[i],puncte[j]);
    fout<<best;
    return 0;
}