Cod sursa(job #1776505)

Utilizator eragon0502Dumitrescu Dragos eragon0502 Data 11 octombrie 2016 14:28:43
Problema Orase Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <cstdio>

using namespace std;

int main()
{
    freopen("orase.in","r",stdin);
    freopen("orase.out","w",stdout);
    int max1=0,dmax,n,d1,d2,i,max2=0;
    scanf("%d %d",&dmax,&n);
    for(i=1;i<=n;++i)
        {
            scanf("%d %d",&d1,&d2);
            if(max1<d1+d2)
                max1=d1+d2;
            if(max2<dmax-d1+d2)
                max2=dmax-d1+d2;
        }
    printf("%d",max1+max2-dmax);
    return 0;
}