dp法。一维。maxint[i]表示到第i颗导弹为止最多拦截的导弹数目。
技巧:temp
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <vector>
#include <cmath>
#include <cstring>
#include <array> #include <algorithm>
using namespace std;
int maxint[2000];
int b[2000];
int main()
{
int i,j,n,k;
cin>>n;
for(i=1;i<=n;i++){
cin>>b[i];
}
maxint[1]=1;
for(i=1;i<=n;i++){
int temp=0;
for(j=1;j<i;j++){
if(b[i]<=b[j]){
if(temp<maxint[j]) temp=maxint[j];
}
}
maxint[i]=temp+1;
}
int max=-1;
for(i=1;i<=n;i++){
if(maxint[i]>max) max=maxint[i];
}
cout<<max;
}