'commit'
This commit is contained in:
29
TangDou/AcWing/LIS/1012_2.cpp
Normal file
29
TangDou/AcWing/LIS/1012_2.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
typedef pair<int, int> PII;
|
||||
#define x first
|
||||
#define y second
|
||||
|
||||
const int N = 5010;
|
||||
PII a[N]; // 南岸和北岸的一对友好城市的坐标
|
||||
int f[N], fl; // 数组模拟栈
|
||||
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);
|
||||
|
||||
f[++fl] = a[1].y;
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (a[i].y > f[fl])
|
||||
f[++fl] = a[i].y;
|
||||
else
|
||||
*lower_bound(f + 1, f + 1 + fl, a[i].y) = a[i].y;
|
||||
}
|
||||
|
||||
printf("%d\n", fl);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user