最长上升子序列

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
using namespace  std ;
const int maxn=100020;
const int inf=0x3f3f3f3f;
int dp[maxn];
int a[maxn];
int n;
int LIS(int a[],int n)
{
    memset(dp,inf,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        *lower_bound(dp,dp+n,a[i])=a[i];
    }
    int len=lower_bound(dp,dp+n,inf)-dp;
    return len;
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        cout<<LIS(a,n)<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/scottding/p/4337695.html