最长上升子序列

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack>
#include<map>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
#define sc1(a) scanf("%lld",&a)
#define pf1(a) printf("%lld\n",a)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
const LL INF=1e18;
const ull base=2333;
const int maxn=1e1+55;
const int maxm=1e4+50;
const int maxv=1e6+5;
const int maxk=1e8+5;
const int mod=1e9+7;
int num[10]={3,6,3,2,4,6,7,5,4,3};
int d[100],g[100];//d[i]表示以i结尾的最长上升子序列长度  g[i]表示长度为i的最长上升子序列末尾最小值
int main()
{
    int ans=-1;
    for(int i=0;i<10;i++) g[i]=mod;
    for(int i=0;i<10;i++)
    {
        int j=lower_bound(g,g+10,num[i])-g;
        d[i]=j+1;
        if(d[i]>ans) ans=d[i];
        g[j]=num[i];
    }
    cout<<ans<<endl;
    return 0;
}
/**

*/

 

posted @ 2020-03-26 17:54  执||念  阅读(121)  评论(0编辑  收藏  举报