HHCY @ 2017-09-07 13:38:10
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int n,wa[100002],wb[100002],a[100002],b[100002],f[100002];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
wa[a[i]]=i;
}
for(int i=1;i<=n;i++)
{
scanf("%d",&b[i]);
wb[b[i]]=i;
}
for(int i=1;i<=n;i++)
f[i]=-999999;
for(int i=1;i<=n;i++)
{
if(a[i]==b[i])
f[i]=f[i-1]+1;
else
f[i]=max(f[i-1],max(f[wb[a[i]]]+1,f[wa[b[i]]]+1));
}
printf("%d",f[n]);
return 0;
}
by HHCY @ 2017-09-07 13:46:32
好吧我知道错了