提交时间:2024-03-30 15:48:17
运行 ID: 140542
#include<bits/stdc++.h> using namespace std; int a[100005],f[100005],n,lo; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(f[lo]<=a[i]) f[++lo]=a[i]; else{ int l=0,r=lo; while(l<=r){ int m=(l+r)>>1; if(f[m]<=a[i]){ l=m+1; if(f[l]>a[i]) break; } else r=m-1; } f[l]=a[i]; } } cout<<lo<<endl; }