这道题思路简单!
1 #include <cstdio>
2 #include <algorithm>
3 using namespace std;
4
5 int main()
6 {
7 int s1[1000];
8 int s2[1000];
9 int m;
10 scanf ( "%d",&m );
11 for ( int i = 0; i != m; ++i )
12 {
13 scanf ( "%d",&s1[i] );
14 s2[i] = 1;
15 }
16 int max1 = 0;
17 int max2;
18 for ( int i = 0; i != m; ++i )
19 {
20 max2 = 0;
21 for ( int j = 0; j != i; ++j )
22 {
23 if ( s1[i] > s1[j] )
24 max2 = max( max2,s2[j] );
25 }
26 s2[i] += max2;
27 if ( s2[i] > max1 )
28 max1 = s2[i];
29 }
30 printf ( "%d\n",max1 );
31 }