Pagini recente » Cod sursa (job #2208658) | Cod sursa (job #3121947) | Cod sursa (job #934784) | Cod sursa (job #2792216) | Cod sursa (job #2334918)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("orase.in");
ofstream fout("orase.out");
pair <int,int>v[60000],best;
int n,i;
unsigned long long maxx;
int main()
{
fin>>n>>n;
for(i=1;i<=n;i++)
fin>>v[i].first>>v[i].second;
sort(v+1,v+n+1);
best=v[1];
for(i=2;i<=n;i++){
if(v[i].first-best.first+best.second+v[i].second>maxx){
maxx = v[i].first - best.first + best.second + v[i].second;
}
if(v[i].first - best.first + best.second < v[i].second)
best=v[i];
}
fout<<maxx;
}