题解 | #拦截导弹#
拦截导弹
https://www.nowcoder.com/practice/dad3aa23d74b4aaea0749042bba2358a?tpId=40&rp=1&ru=%2Fta%2Fkaoyan&qru=%2Fta%2Fkaoyan&difficulty=&judgeStatus=&tags=&title=77&sourceUrl=&gioEnter=menu
#include <stdio.h> int main() { int a; while (scanf("%d", &a) != EOF) { int arr[a]; for (int i=0;i<a;i++){ scanf("%d", &arr[i]); } int dp[a]; dp[a-1]=1; for (int i=a-2;i>=0;i--){ dp[i]=1; for (int j=i+1;j<a;j++){ int temp=1; if(arr[i]>=arr[j]){ temp+=dp[j]; if (temp>dp[i]){ dp[i]=temp; } } } } int max=1; for (int i=0;i<a;i++){ if(dp[i]>0&&dp[i]<=a){ if (max<dp[i]){ max = dp[i]; } } } printf("%d\n", max); } return 0; }#c#