Pagini recente » Cod sursa (job #2062881) | Cod sursa (job #1090206) | Cod sursa (job #1411755) | Cod sursa (job #1632838) | Cod sursa (job #1479672)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
vector<pair<int,int> > V;
int Max,aux;
int N,M,D,L;
int main()
{
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
scanf("%d%d",&M,&N);
for(int i=1;i<=N;i++)
{
scanf("%d%d",&D,&L);
V.push_back(make_pair(D,L));
}
sort(V.begin(),V.end());
for(auto it:V)
{
Max=max(Max,it.first+it.second+aux);
aux=max(aux,it.second-it.first);
}
printf("%d",Max);
}