题解 | #拦截导弹#
拦截导弹
https://www.nowcoder.com/practice/dad3aa23d74b4aaea0749042bba2358a
且记作dp类型吧
#include <cstring>
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
while(cin >> k){
int nums[k];
int dp[k + 1];
for(int i = 0; i < k; i++){
cin >> nums[i];
dp[i] = 1;
}
int maxInt = -1;
for(int i = 0; i < k; i++){
for(int j = 0; j< i; j++){
if(nums[j] >= nums[i]){
dp[i] = max(dp[i],dp[j] + 1);
}
}
maxInt = max(dp[i],maxInt);
}
cout << maxInt << endl;
}
}
// 64 位输出请用 printf("%lld")