Cod sursa(job #2667030)

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

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

int main()
{
    int n,m,ddr=0,dsta=0;
    fin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        int st, dr;
        fin>>st>>dr;
        if (st+dr>ddr)
        {
            ddr=st+dr;
        }
        if (dr-st>dsta)
        {
            dsta=dr-st;
        }
    }
    fout<<dsta+ddr;
    fin.close();
    fout.close();
    return 0;
}