提交时间:2024-03-30 15:37:02
运行 ID: 140484
#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)/2; if(f[mid]==x)return mid; if(f[mid]<x){ l=mid+1; }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; }