提交时间:2024-03-30 15:43:48
运行 ID: 140514
#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; res=mid; }else { r=mid-1; } } return res; } 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; }