提交时间:2024-03-30 15:41:55
运行 ID: 140507
#include<bits/stdc++.h> using namespace std; const int N=1100; int w[N],f[N],maxn=0,top; int g(int x){ int l=1 ,r=top,res; while(l<=r){ int mid=(l+r)>>1; if(f[mid]<=x){ l=mid+1; if(f[l]>x)break; }else { r=mid-1; } } return l; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++)cin>>w[i]; for(int i=1;i<=n;i++){ if(f[top]<=w[i])f[++top]=w[i]; else f[g(w[i])]=w[i]; } cout<<top; }