求助:样例过不了

P1439 【模板】最长公共子序列

wxy2005 @ 2019-01-26 15:29:14

#include<iostream>
#include<cmath>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<cstring>
#include<vector>
#define MAXN 100005
using namespace std;
int n,a[MAXN],b[MAXN],c[MAXN],cnt=1,ans[MAXN],len=0,sta;
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(c[a[i]]!=0)
            c[a[i]]=cnt++;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        b[i]=c[b[i]];
    }
    for(int i=1;;i++)
    {
        if(b[i]!=0)
        {
            ans[++len]=b[i];
            sta=i+1;
            break;
        } 
    }
    for(int i=sta;i<=n;i++)
    {
        if(b[i]==0)
        continue;
        if(ans[len]<=b[i])
            ans[++len]=b[i];
        else
            ans[upper_bound(ans,ans+MAXN-1,b[i])-ans]=b[i];
    }
    printf("%d",len);
    return 0;
}

by xiaolou @ 2019-01-26 15:35:29

@王翔宇 哇,巨佬


by wxy2005 @ 2019-01-26 15:40:38

@xiaolou 我巨个啥啊,您这道题都AC了


by memset0 @ 2019-01-26 15:40:39

@王翔宇 哇,巨佬


by wxy2005 @ 2019-01-26 15:41:15

@memset0 QAQ what?


by xiaolou @ 2019-01-26 15:41:32

@memset0 您出镜率吊打chen_zhe啊。。。


by wxy2005 @ 2019-01-26 15:41:54

@memset0 您估值排名第三,说我这样的垃圾巨??


by wxy2005 @ 2019-01-26 15:42:21

@xiaolou 这叫新官上任三把火


|