倒置数组 求该数组的最长上升子序列即可
#include<bits/stdc++.h>
using namespace std;
const int maxn=10101;
int dp[maxn],n,a[maxn],tmp[maxn],mx=-101011;
int main()
{
memset(dp,0,sizeof(dp));
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i];
for(int i=1; i<=n; i++)
tmp[n-i+1]=a[i];//倒置桩子 求最长上升子序列
for(int i=1; i<=n; i++)
{
dp[i]=1;
for(int j=1; j<i; j++)
{
if(tmp[j]<=tmp[i])
{
dp[i]=max(dp[i],dp[j]+1);
}
}
mx=max(mx,dp[i]);
}
printf("%d\n",mx);
return 0;
}