标签:https class 树状 += oid const main pac amp
#include<bits/stdc++.h>
#define R register int
#define low(x) (x&(-x))
using namespace std;
const int N=20001;
const int M=500001;
int n,m,w[M],f[M],tot,ans,te[M];
vector<int>G[N];
void add(R x,R v){while(x<=m)te[x]=max(te[x],v),x+=low(x);}
int query(R x){R v=0;while(x)v=max(te[x],v),x-=low(x);return v;}
int gi(){
R x=0,k=1;char c=getchar();
while(c!=‘-‘&&(c<‘0‘||c>‘9‘))c=getchar();
if(c==‘-‘)k=-1,c=getchar();
while(c>=‘0‘&&c<=‘9‘)x=(x<<3)+(x<<1)+c-‘0‘,c=getchar();
return x*k;
}
int main(){
n=gi(),m=n*5;
for(R i=1,u;i<=m;++i)
u=gi(),G[u].push_back(i);
for(R i=1,u;i<=m;++i){
u=gi();
for(R j=4;j>=0;--j)w[++tot]=G[u][j];
}
for(R i=1;i<=tot;++i)
f[i]=query(w[i]-1)+1,add(w[i],f[i]),ans=max(ans,f[i]);
cout<<ans<<endl;
return 0;
}
标签:https class 树状 += oid const main pac amp
原文地址:https://www.cnblogs.com/Tyher/p/9898976.html