div.2/Bellovin<最长上升子序列>

题意:

序列arr[i--n];输出以a[i]为结尾的最长上升子序列。1<=n<=100000;

思路:

O(n*log(n)),求最长上升子序列。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100000+100;
int arr[maxn];
int main ()
{
    int T;scanf("%d",&T);
    while(T--)
    {
        int n,k=0;scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            int t;
            scanf("%d",&t);
            int pos=int(lower_bound(arr,arr+k,t)-arr);
            printf("%d",pos+1);
            if(i<n)
                printf(" ");
            if(pos==k)
                k++;
            arr[pos]=t;
        }
        printf("
");
    }
    return 0;
}
想的太多,做的太少。
原文地址:https://www.cnblogs.com/pealicx/p/6115616.html