nyoj 79 拦截导弹 (动态规划)

时间:2021-10-11 05:37:57

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=79

题意即求最长单调递减子序列

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 22

int h[N];
int d[N];

int main()
{
    freopen("d:\\in.txt", "r", stdin);
    int t, n;
    cin>>t;
    while(t--){
        cin>>n;
        ; i<n; i++)
            cin>>h[i];
        ;
        ; i>=; i--){
            d[i] = ;
            ; j<n; j++){
                if(h[j] < h[i])
                    d[i] = max(d[i], d[j]+);
            }
            ans = max(ans, d[i]);
        }
        cout<<ans<<endl;
    }
}