题解 | #拦截导弹#
拦截导弹
https://www.nowcoder.com/practice/dad3aa23d74b4aaea0749042bba2358a
#include <iostream> using namespace std; int arr[28]; int Fun(int n){ int ans; if(n==0){ ans = 1; }else{ ans = 1; for(int i=n-1;i>=0;i--){ if(arr[i]>=arr[n]){ ans = max(ans,Fun(i)+1); } } } return ans; } int main() { int n; cin >> n; for(int i=0;i<n;i++){ cin>>arr[i]; } int maxn = 0; for(int i=0;i<n;i++){ maxn = max(maxn,Fun(i)); } cout<<maxn<<endl; }