http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1299
View Code
1 #include<stdio.h> 2 #include<string.h> 3 #define Max 1000 4 int b[Max+10] ; 5 int maxlen[Max+10] ; 6 int main() 7 { 8 int m, n, i, j ; 9 scanf("%d", &n) ; 10 for(i=1; i<=n; i++) 11 scanf("%d", &b[i]) ; 12 maxlen[1] = 1 ; 13 for(i=2; i<=n; i++) 14 { 15 m = 0 ; 16 for(j=1; j<i; j++) 17 if(b[i]>b[j]) 18 if(m<maxlen[j]) 19 m = maxlen[j] ; 20 maxlen[i] = m + 1 ; 21 } 22 int nmax = -1 ; 23 for(i=1; i<=n; i++) 24 if(nmax<maxlen[i]) 25 nmax = maxlen[i] ; 26 printf("%d\n", nmax) ; 27 return 0 ; 28 }