#include using namespace std; typedef pair PII; #define x first #define y second const int N = 5010; PII a[N]; // 南岸和北岸的一对友好城市的坐标 int f[N]; // 记录以f[i]为结尾的一对友好城市时的,不产生交叉的最多城市对数 int n; // n组友好城市 int res; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y; sort(a + 1, a + 1 + n); // PII默认按第一维度first进行排序 // LIS for (int i = 1; i <= n; i++) { f[i] = 1; for (int j = 1; j < i; j++) if (a[i].y > a[j].y) f[i] = max(f[i], f[j] + 1); res = max(res, f[i]); } printf("%d\n", res); return 0; }