提交时间:2024-03-30 15:50:50
运行 ID: 140551
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N] , f[N]; int n , lon; int main() { int n; cin >> n; for(int i = 1;i <= n;i++) { cin >> a[i]; if(f[lon] <= a[i]) f[++lon] = a[i]; else { int l = 0 , r = lon; while(l <= r) { int mid = (l + r) / 2; if(f[mid] <= a[i]) { l = mid + 1; if(f[l] > a[i]) break; } else r = mid--; f[l] = a[i]; } } } cout << lon; return 0; }