上升点列丐版
作者:
jy9
,
2024-09-28 11:57:17
,
所有人可见
,
阅读 1
#include <iostream>
#include <cmath>
#include <algorithm>
#define int long long
using namespace std;
const int N = 1010;
int n, k;
struct node{
int x, y;
bool operator < (const node &p)const{
if(x != p.x)return x < p.x;
else return y < p.y;
}
}a[N];
int dp[N];
int oj(node a, node b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int mhd(node a, node b){
return abs(a.x-b.x) + abs(a.y-b.y);
}
int ans = 1;
signed main(){
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i].x >> a[i].y;
dp[i] = 1;
}
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 && mhd(a[i], a[j]) == 1){
dp[i] = max(dp[i], dp[j]+1);
}
}
}
for(int i = 1; i <= n; i++){
ans = max(ans, dp[i]);
}
cout << ans+k;
return 0;
}