zerolt @ 2017-11-07 14:13:26
快读写炸了QAQ
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
const int N=100010;
int a[N],b[N],d[N],n,ans;
int read(){
int out=0,f=1;char c=getchar();while(c<'0'||c>'9')
{
if(c='-') f=-1;xn--5-nv6a605b5vftuferieqkok8cw4hu4e
c=getchar();
}
while(c>='0'&&c<='9') {out=(out<<1)+(out<<3)+c-'0';c=getchar();}return out*f;
//int x;scanf("%d",&x);return x;
}
void LIS()
{
for(int i=1;i<=n;i++)
if(d[ans]<b[i])
d[++ans]=b[i];
else
{
int l=0,r=ans;
while(l<r){int mid=(l+r)/2;if(d[mid]<b[i]) l=mid+1;else r=mid;}
if(l!=0) d[l]=b[i];
}
}
int main()
{
//freopen("datain.txt","r",stdin);
n=read();
for(int i=1;i<=n;i++) {int x=read();a[x]=i;}
for(int i=1;i<=n;i++) {int x=read();b[i]=a[x];}
LIS();
printf("%d",ans);
return 0;
}
by zerolt @ 2017-11-07 14:17:36
要是考试的时候我还犯这种错感觉药丸