#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
const int N = 5010;
int n;
PII city[N];
int f[N];
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i ++ ) scanf("%d%d", &city[i].first, &city[i].second);
sort(city, city + n);
int res = 0;
for (int i = 0; i < n; i ++ )
{
f[i] = 1;
for (int j = 0; j < i; j ++ )
if(city[j].second<city[i].second)
f[i]=max(f[i],f[j]+1);
res = max(res, f[i]);
}
printf("%d\n", res);
return 0;
}
友好城市(最长上升子序列)
最新推荐文章于 2021-03-12 00:10:08 发布