杭电1257

 1 //只需要一个数组存可用系统最高拦截高度
 2 #include<stdio.h>
 3 int s[6000];
 4 int main()
 5 {
 6     int n;
 7     while(~scanf("%d",&n))
 8     {
 9         int ans=1,top=-1,x,i,j;
10         for(i=0; i<n; ++i)
11         {
12             scanf("%d",&x);
13             if(top==-1)
14                 s[++top]=x;
15             else
16             {
17                 for(j=0; j<=top; ++j)
18                 {
19                     if(s[j] >= x)
20                     {
21                         s[j]=x;
22                         break;
23                     }
24                 }
25                 if(j > top)
26                 {
27                     ++ans;
28                     s[++top]=x;
29                 }
30             }
31         }
32         printf("%d
",ans);
33     }
34 }
原文地址:https://www.cnblogs.com/qq188380780/p/6407365.html