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

运行 ID: 140544

#include<bits/stdc++.h> using namespace std; int a[114514],f[114514],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; return 0; }