study-cpp/mooc/导弹拦截.cpp

23 lines
580 B
C++

#include <iostream>
int main(){
int a[1001],fall[1001],rise[1001],n=0,most=0,least=0;
while(std::cin>>a[++n]){
for(int i=0;i<=n;i++){
fall[i]=1;
rise[i]=1;
for(int j=0;j<i;j++){
if(a[i]<=a[j]){
fall[i]=std::max(fall[i],fall[i+1]);
}
if(a[i]>a[j]){
rise[i]=std::max(rise[i],rise[i+1]);
}
}
most=std::max(most,fall[i]);
least=std::max(least,rise[i]);
}
}
return 0;
}