小墨在努力!!
吗了个b的。。。。。
 1 Source Code
2
3 Problem: 1887 User: XXX
4 Memory: 240K Time: 63MS
5 Language: C++ Result: Accepted
6
7 Source Code
8 #include <stdio.h>
9 int main()
10 {
11 int num[10000] ,total ,i ,j ,k ,Max ,max ,dp[10000] = {1};
12 for(k = 1 ; ;k++)
13 {
14 total = -1 ,Max = 1;
15 do{
16 total++;
17 scanf("%d",&num[total]);
18 }while(num[total] != -1);
19 if(total == 0) break;
20 for(i = 1 ;i < total ;i++)
21 {
22 dp[i] = 1 ,max = 0;
23 for(j = 0 ;j < i ;j++)
24 {
25 if(num[i] < num[j] && dp[j] > max)
26 max = dp[j];
27 }
28 dp[i] = max + 1;
29 if(dp[i] > Max) Max = dp[i];
30 }
31 printf("Test #%d:\n maximum possible interceptions: %d\n\n" ,k ,Max);
32 }
33 return 0;
34 }

O(n2)的时间复杂度。。。。

O(nlnn)还不会。。。。

posted on 2012-02-26 11:30  小墨在努力!!  阅读(150)  评论(0编辑  收藏  举报