求最长上升子序列(动态规划入门)
int n;cin>>n;
vector<int> dp(n+1),a(n+1),f(n+1);
for(int i=1;i<=n;i++) cin>>a[i];
int len=1;
f[1]=a[1];
for(int i=2;i<=n;i++){
int l=0,r=len,mid,ans;
if(a[i]>f[len]) f[++len]=a[i];
else{
while(l<=r){
mid=l+r>>1;
if(f[mid]>=a[i]){
ans=mid;r=mid-1;
}
else l=mid+1;
}
f[ans]=a[i];
}
}
cout<<len<<endl;