题解 | #拦截导弹#
拦截导弹
https://www.nowcoder.com/practice/dad3aa23d74b4aaea0749042bba2358a
#include<cstdio> #include<iostream> #define N 25 using namespace std; int main() { int n; int ans = 0; int dp[N]; int height[N]; scanf("%d", &n); for (int i = 0 ; i < n ; ++i) { scanf("%d", &height[i]); } for (int i = 0 ; i < n ; ++i) { dp[i] = 1; for (int j = 0 ; j < i ; ++j) { if (height[j] >= height[i]) { dp[i] = max(dp[j] + 1, dp[i]); } } ans = max(ans, dp[i]); } printf("%d\n", ans ); }