完成“导弹拦截”
This commit is contained in:
parent
ce649523f8
commit
46bed7f87b
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"C_Cpp.default.compilerPath": "c:\\Users\\Administrator\\Downloads\\llvm-mingw-20240619-ucrt-x86_64\\llvm-mingw-20240619-ucrt-x86_64\\bin\\aarch64-w64-mingw32-clang++.exe"
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#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;
|
||||
}
|
Loading…
Reference in New Issue