noi 8780 拦截导弹

题目链接:

http://noi.openjudge.cn/ch0206/8780/

LDS

也可以转换为LIS

#include <bits/stdc++.h>

using namespace std;

int a[50000];
const int inf = 0x3f3f3f3f;
int g[50000];
int d[50000];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF) {
       for(int i=0;i<n;i++)
            scanf("%d",&a[n-i-1]);
       memset(g,inf,sizeof(g));

       int ans = 0;
       for(int i=0;i<n;i++) {

            int k = lower_bound(g+1,g+1+n,a[i])-g;
            d[i] = k;
            ans = max(ans,d[i]);
            g[k] = a[i];
       }

       printf("%d
",ans);


    }
    return 0;
}
原文地址:https://www.cnblogs.com/TreeDream/p/6023769.html