Cod sursa(job #1775730)
Utilizator | Data | 10 octombrie 2016 17:35:57 | |
---|---|---|---|
Problema | Orase | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("orase.in");
ofstream out("orase.out");
int m,n,x,i,y,st=0,dr=0;
in>>m>>n;
for(i=1;i<=n;i++)
{
in>>x>>y;
if(x+y>st)
st=x+y;
if(m-x+y>dr)
dr=m-x+y;
}
out<<st+dr-m;
return 0;
}