POJ 2533 Longest Ordered Subsequence

 1 /**************************************
 2Problem: POJ 2533 Longest Ordered Subsequence
 3Time: 0MS
 4Memory: 136K
 5Accepted Time: 2009-04-11 12:51:01
 6Tips:《程序设计导引及在线实践》10.3
 7**************************************/

 8 #include  < stdio.h >
 9 int  main()
10 {
11    int n;
12    while(scanf("%d",&n)!=EOF)
13    {
14        int a[1009],i,j,max;
15        for(i=1;i<=n;i++)scanf("%d",&a[i]);
16        int b[1009];
17        b[1]=1;
18        for(i=1;i<=n;i++)
19        {
20            max=0;
21            for(j=1;j<i;j++)
22            {
23                if(a[i]>a[j]&&b[j]>max)
24                {
25                    max=b[j];
26                }

27            }

28            b[i]=max+1;
29        }

30        max=0;
31        for(i=1;i<=n;i++)
32        if(max<b[i])
33        {
34            max=b[i];
35        }

36        printf("%d\n",max);
37    }

38    return 0;
39}

40

你可能感兴趣的:(sequence)