#include <iostream>
using namespace std;
#define MAXSIZE 100
int max(
int num1,
int num2)
{
return num1>num2?
num1:num2;
}
int main()
{
int num[MAXSIZE];
int maxLen[MAXSIZE];
int n;
int i;
int j;
int maxA =
1;
cin >>
n;
for (i=
0; i<n; i++
)
{
cin >>
num[i];
maxLen[i] =
1;
}
for (i=
1; i<n; i++
)
for (j=
0; j<i; j++
)
if (num[i] >
num[j])
maxLen[i] = max(maxLen[i], maxLen[j]+
1);
for (i=
1; i<n; i++
)
if (maxLen[i] >
maxA)
maxA =
maxLen[i];
cout << maxA <<
endl;
return 0;
}
转载于:https://www.cnblogs.com/jlbs/p/6485883.html
相关资源:最长上升子序列优化代码