Pagini recente » Cod sursa (job #3159591) | Cod sursa (job #377215) | Cod sursa (job #2757138) | Cod sursa (job #862373) | Cod sursa (job #261190)
Cod sursa(job #261190)
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
//#define NMAX 50002
vector< pair< int,int > > V;
int main()
{
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
int N,M;
scanf("%d%d",&N,&M);
int i,a1,a2;
for(i=1; i<=N; ++i)
{
scanf("%d%d\n",&a1,&a2);
V.push_back( make_pair(a1,a2) );
}
sort( V.begin(), V.end() );
int p1;
int q2=V[0].first,c2=V[0].second;
int ANS=-1;
for(p1=1; p1<N; ++p1)
{
a1= V[ p1 ].first - q2 + V[ p1 ].second + c2;
if( a1>ANS ) ANS=a1;
if( V[ p1 ].second > a1- V[ p1 ].second )
q2=V[ p1 ].first,c2=V[ p1 ].second;
}
printf("%d\n",ANS);
return 0;
}