提交时间:2024-03-30 15:48:13
运行 ID: 140541
#include<bits/stdc++.h> using namespace std; int a[100005],f[100005],l,n; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; if(f[l]<=a[i])f[++l]=a[i]; else{ int L=0,R=l; 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<<l<<endl; return 0; }