Cod sursa(job #2667047)

Utilizator georgecristian2002Raducanu George-Cristian georgecristian2002 Data 2 noiembrie 2020 19:52:47
Problema Orase Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
using namespace std;

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

int main()
{
    int n,m,l,d,smax=0,dmax=0;
    fin>>m>>n;
    for(int i=1; i<=n; i++)
    {
        fin>>d>>l;
        if(d+l>smax)
            smax = d+l;//cel mai lung din dreapta
        if(l-d>dmax)
            dmax = l-d;//cel mai lung din stanga
    }
    fout<<smax+dmax;
    fin.close();
    fout.close();
    return 0;
}