You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
906 B
41 lines
906 B
2 years ago
|
#include <cstdio>
|
||
|
#include <cstring>
|
||
|
#include <algorithm>
|
||
|
#include <iostream>
|
||
|
#include <cmath>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
const int N = 510;
|
||
|
const int M = 110;
|
||
|
struct Node {
|
||
|
int x, y;
|
||
|
bool operator<(const Node &t) const {
|
||
|
if (x == t.x) return y < t.y;
|
||
|
return x < t.x;
|
||
|
}
|
||
|
} a[N];
|
||
|
int f[N][M];
|
||
|
int ans;
|
||
|
int main() {
|
||
|
int n, m;
|
||
|
cin >> n >> m;
|
||
|
|
||
|
for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
|
||
|
sort(a + 1, a + 1 + n);
|
||
|
|
||
|
for (int i = 1; i <= n; i++)
|
||
|
for (int j = 1; j < i; j++) {
|
||
|
if (a[i].y < a[j].y) continue;
|
||
|
|
||
|
int d = a[i].x - a[j].x + a[i].y - a[j].y - 1;
|
||
|
|
||
|
for (int k = 0; k <= m - d; k++) {
|
||
|
f[i][k + d] = max(f[i][k + d], f[j][k] + d + 1);
|
||
|
|
||
|
ans = max(ans, f[i][k + d] + m - k - d);
|
||
|
}
|
||
|
}
|
||
|
printf("%d\n",ans);
|
||
|
return 0;
|
||
|
}
|