提交时间:2024-03-30 15:47:20

运行 ID: 140534

#include<bits/stdc++.h> using namespace std; int a[100010],f[100010],n,top; signed main(){ cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i]; if(f[top] <= a[i])f[++top] = a[i]; else{ int l = 0,r= top; while(l <= r){ int mid = (l+r)>>1; if(f[mid] <=a[i]){ l = mid +1; if(f[l] > a[i]) break; }else{ r = mid-1; } } f[l] = a[i]; } } cout << top << endl; return 0; }