Cod sursa(job #1486765)
Utilizator | Data | 15 septembrie 2015 16:33:34 | |
---|---|---|---|
Problema | Orase | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <limits>
#include <algorithm>
#define INF numeric_limits<int>::max()
using namespace std;
ifstream in("orase.in");
ofstream out("orase.out");
pair<int,int> a[50001];
int n,m;
int main()
{
in>>m>>n;
for(int i=1;i<=n;i++)
in>>a[i].first>>a[i].second;
//sort(a+1,a+n+1);
int mx=-INF,sol=-INF;
for(int i=1;i<=n;i++)
{
sol=max(sol,a[i].first+a[i].second+mx);
mx=max(mx,a[i].second-a[i].first);
}
out<<sol<<'\n';
return 0;
}