Cod sursa(job #2334756)

Utilizator Dragne.Andrei11Dragne Andrei Dragne.Andrei11 Data 3 februarie 2019 00:00:22
Problema Orase Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <bits/stdc++.h>
#define INF 3000005

using namespace std;

const int nmax=50005;

int d[nmax];
int l[nmax];

int main()
{
    freopen("orase.in", "r", stdin);
    freopen("orase.out", "w", stdout);
    int m, n, rasp=-INF;

    scanf("%d%d", &m, &n);
    for(int i=1;i<=n;i++)
        scanf("%d%d", &d[i], &l[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(d[i]<d[j])
                rasp=max(rasp, l[i]+l[j]+d[j]-d[i]);
            else
                rasp=max(rasp, l[i]+l[j]+d[i]-d[j]);
        }
    }
    printf("%d\n", rasp);

    return 0;
}