提交时间:2024-03-30 15:48:04

运行 ID: 140539

#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)/2; if(mid<=a[i]){ l=mid+1; if(f[l]>a[i])break; }else r=mid-1; } f[l]=a[i]; } } cout<<longest<<endl; }