Cod sursa(job #2365572)

Utilizator Xutzu358Ignat Alex Xutzu358 Data 4 martie 2019 14:49:40
Problema Orase Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("orase.in");
ofstream g("orase.out");
int n,m,c1,c2,max1,max2,l1,l2;
int main()
{
    f >> m >> n;
    for (int i=1;i<=n;i++) {
        f >> c1 >> c2;
        if (c1+c2>max1) {
            max1=c1+c2;
            l1=c1;
        }
        else if (c1+c2>max2) {
            max2=c1+c2;
            l2=c2;
        }
    }
    if (c1>c2) {
        g << max1+max2-(c1-c2-1);
    }
    else {
        g << max1+max2-(c2-c1-1);
    }
    return 0;
}