Cod sursa(job #1773773)

Utilizator mateilmatei lascu mateil Data 8 octombrie 2016 10:55:18
Problema Orase Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>

using namespace std;
int l[50000], d[50000];
int main()
{
    ifstream f("orase.in");
    ofstream g("orase.out");
    int n,m,max = 0, i,j,x;
    f>>n>>m;
    f>>d[0]>>l[0];
    for(i = 1; i < n; i++){
       f>>d[i]>>l[i];
       for(j = 0; j < i; j++){
         x = d[i] - d[j];
         if(x < 0)
          x = x * (-1);
         if(max < x + l[i] + l[j])
           max = x + l[i] + l[j];
       }
    }
    g<<max;
    return 0;
}