Cod sursa(job #1950270)

Utilizator GoogalAbabei Daniel Googal Data 2 aprilie 2017 20:58:36
Problema Orase Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <fstream>

using namespace std;

ifstream in("orase.in");
ofstream out("orase.out");

int const INF = -100000000;
int const DIM = 1000000;

int n, m, ms, md, poz;
char buff[DIM];

int read(){
  int x = 0;
  while(!isdigit(buff[poz]))
    if(++poz == DIM)
      in.read(buff,DIM), poz = 0;

  while(isdigit(buff[poz])){
    x = x * 10 + (buff[poz] - '0');
    if(++poz == DIM)
      in.read(buff,DIM), poz = 0;
  }

  return x;
}

int main()
{
  int a, b;
  ms = md = INF;
  n = read();
  m = read();
  for(int i = 1; i <= m; i++){
    a = read();
    b = read();
    ms = max(ms, a + b);
    md = max(md, b - a);
  }

  out << ms + md;

  in.close();
  out.close();
  return 0;
}