最爱康娜酱 @ 2018-11-07 17:28:24
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=100005;
int a[maxn],b[maxn],map[maxn],c[maxn],stk[maxn],up;
int main(){
int n;
scanf("%d",&n);
for(int
i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++)
{
scanf("%d",&b[i]);
map[b[i]]=i;
}
for(int i=1;i<=n;i++)
{
c[i]=map[a[i]];
}
stk[0]=-100005;
for(int i=1;i<=n;i++)
{
if(c[i]>stk[up])
{
stk[++up]=c[i];
}
else
{
int l=1,r=up,m;
while(l<=r)
{
m=(l+r)/2;
if(c[i]>stk[m])l=m+1;
else
r=m-1;
}
stk[m]=c[i];
}
}
cout<<up<<endl;
return 0;
}