8 389 207 155 300 299 170 158 65
2
注:要记录每个系统能截的高度,不要犯“只与”上一个能截系统的最大高度比较的错误啊
!
代码实现:
import java.util.*;
class Main{
public static void main(String[] args){
int n,i,x,numb,m,k;
int[] system=new int[100000];//记录所有系统中能截的最大高度
Scanner sc=new Scanner(System.in);
boolean haveSystem;//记录在已有的系统只是否找到能截的系统
while(sc.hasNext()){
numb=0;//表示系统的个数
n=sc.nextInt();
for(i=0;i<n;i++){
m=sc.nextInt();
haveSystem=false;
for(k=0;k<=numb;k++){//先找再已有的系统只是否有能截的系统
if(m<=system[k]){
system[k]=m;
haveSystem=true;
break;
}
}
if(!haveSystem){//若没有能截的系统,则重新配一套系统
system[++numb]=m;
}
}
System.out.println(numb);
}
}
}
原文:http://blog.csdn.net/u011479875/article/details/45037495