Pagini recente » Cod sursa (job #3264750) | Cod sursa (job #1834986) | Cod sursa (job #1001994) | Cod sursa (job #131911) | Cod sursa (job #829394)
Cod sursa(job #829394)
#include <cstdio>
#include <algorithm>
#define NMAX 50020
using namespace std;
struct City {
long x , y;
void make (const long &xx , const long &yy) {
x = xx;
y = yy;
}
};
class MyComp {
public :
bool operator () (const City &A , const City &B) {
return (A.x < B.x);
}
};
City O [NMAX];
void Read (long &N , long &M) {
long x , y;
scanf ("%ld%ld" , &N , &M);
for (long i = 1 ; i <= N ; i ++) {
scanf ("%ld%ld" , &x , &y);
O [i].make (x , y);
}
O [++N].make (M , 0);
}
long dist (const long &a , const long &b) {
return O [b].x - O [a].x + O [a].y + O [b].y;
}
void Solve (const long &N , const long &M) {
long i , u , d1 , d2 , max = -1;
sort (O + 1 , O + 1 + N , MyComp ());
u = 1;
for (i = 2 ; i <= N ; i ++) {
d1 = dist (u , i);
d2 = dist (i - 1 , i);
if (d2 > d1)
u = i - 1;
if (d1 > max) max = d1;
if (d2 > max) max = d2;
}
printf ("%ld\n" , max);
}
int main () {
long N , M;
freopen ("orase.in" , "r" , stdin);
freopen ("orase.out" , "w" , stdout);
Read (N , M);
Solve (N , M);
return 0;
}