提交时间:2024-03-30 15:55:41

运行 ID: 140575

#include<bits/stdc++.h> using namespace std; int a[100005],f[100005],n,longest; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(f[longest]<=a[i]) f[++longest]=a[i]; else{ int L=0,R=longest; 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<<longest<<endl; return 0; }