Pagini recente » Cod sursa (job #1011632) | Cod sursa (job #667104) | Cod sursa (job #2713952) | Cod sursa (job #1102680) | Cod sursa (job #460023)
Cod sursa(job #460023)
#include <cstdio>
#include <algorithm>
#define nmax 50010
using namespace std;
struct lol { int L, D; } A[nmax];
int i, n, m, sol, maxL;
inline bool cmp (const lol &a, const lol &b) {
if (a.D < b.D) return 1;
return 0;
}
int main () {
freopen ("orase.in", "r", stdin);
freopen ("orase.out", "w", stdout);
scanf ("%d%d\n", &n, &m);
for (i = 1; i <= n; i++)
scanf ("%d%d\n", &A[i].D, &A[i].L);
random_shuffle (A + 1, A + n + 1);
sort (A + 1, A + n + 1, cmp);
maxL = -nmax;
for (i = 1; i <= n; i++) {
if (sol < A[i].L + A[i].D + maxL) sol = A[i].L + A[i].D + maxL;
if (maxL < A[i].L - A[i].D) maxL = A[i].L - A[i].D;
}
printf ("%d\n", sol);
return 0;
}