71 7 3 5 9 4 8Example Output
4Hint
Author
Northeastern Europe 2002
| 01 | #include<stdio.h> | 
| 02 | intmain() | 
| 03 | { | 
| 04 |     inta[1005], b[1005]; | 
| 05 |     inti, n, max, j; | 
| 06 |     max = 0; | 
| 07 |     scanf("%d", &n); | 
| 08 |     for(i = 1; i <= n; i++) | 
| 09 |     { | 
| 10 |         scanf("%d", &a[i]); | 
| 11 |         b[i] = 0; | 
| 12 |     } | 
| 13 |     b[1] = 1; | 
| 14 |     for(i = 1; i <= n; i++) | 
| 15 |     { | 
| 16 |         b[i] = 1; | 
| 17 |         for(j = 1; j <= i; j++) | 
| 18 |         { | 
| 19 |             if(a[i] > a[j] && b[j] >= b[i]) | 
| 20 |                 b[i] = b[j] + 1; | 
| 21 |         } | 
| 22 |     } | 
| 23 |     for(i = 1; i <= n; i++) | 
| 24 |         if(b[i] > max) max = b[i]; | 
| 25 |     printf("%d/n", max); | 
| 26 |     return0; | 
| 27 | } | 
新聞熱點
疑難解答