Cod sursa(job #2088055)

Utilizator lupascumialupascu maria lupascumia Data 14 decembrie 2017 18:38:18
Problema Orase Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>

using namespace std;
ifstream fin ("orase.in");
ofstream fout ("orase.out");
int n,m,x,y,s,xmax,i,ymax,ymax2;
int main()
{
    fin>>m>>n;
    for(i=1;i<=n;i++)
    {
        s=0;
        fin>>y>>x;
        s+=y+x;
        xmax=max(s,xmax);
        if(y>ymax)
        {
            ymax2=ymax;
            ymax=y;
        }
    }
    if(m>ymax)
    {
        ymax2=ymax;
        ymax=m;
    }
    fout<<ymax+ymax2+xmax;
    return 0;
}