记录途径
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
long long a[1010];
int dp[1010],g[1010];
int cun =1;
int main()
{
int n;
cin >> n;
for(int i=1;i<=n;i)
{
scanf(“%lld”,&a[i]);
}
dp[1]=1;;
for(int i=2;i<=n;i)
{
dp[i]=1;
g[i] =0;
for(int j=1;j<i;j)
{
if(a[j]<a[i])
{
if(dp[i]<dp[j]+1)//
dp[i] =dp[j]+1,g[i]=j;//
}
}
}
int k =1;
for(int i=1;i<=n;i)
{
if(dp[k]<dp[i])
{
k=i;
}
}
cout << dp[n] <<endl;
for(int i=0,len = dp[k];i<len;i++)
{
cout <<a[k];
k = g[k];
}
return 0;
}