Pagini recente » Cod sursa (job #153126) | Cod sursa (job #1061890) | Cod sursa (job #1766439) | Cod sursa (job #176803) | Cod sursa (job #1770238)
#include <fstream>
#include <algorithm>
#define nmax 50001
using namespace std;
ifstream fin("orase.in");
ofstream fout("orase.out");
int m,n,i,rez,v[nmax];
pair < int , int > a[nmax];
int main()
{
fin>>n>>m;
for(i=1;i<=m;i++)
fin>>a[i].first>>a[i].second;
sort(a+1,a+m+1);
for(i=1;i<=m;i++)
{
if(a[i].first+a[i].second-a[i-1].first+v[i-1]>rez)
{
rez=a[i].first+a[i].second-a[i-1].first+v[i-1];
}
v[i]=a[i].second;
}
fout<<rez;
return 0;
}