提交时间:2024-03-30 15:44:59

运行 ID: 140519

#include<iostream> using namespace std; int id=0,a[100001],f[100001]; int ff(int n){ int l=1,r=id,ans=0; while(l<=r){ int mid=(l+r)/2; if(n<f[mid]){ r=mid-1; ans=mid; } else l=mid+1; } return ans; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; f[i]=1; } for(int i=1;i<=n;i++){ if(a[i]>=f[id]){ f[id+1]=a[i]; id++; } else f[ff(a[i])]=a[i]; } cout<<id<<endl; return 0; }