@zzzc18
2017-11-09T11:47:26.000000Z
字数 462
阅读 1098
模板库
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 100000+9;
int n;
int b[MAXN];
int num[MAXN];
int dp[MAXN];
void solve(){
memset(dp,0x7f,sizeof(dp));
for(int i=1;i<=n;i++){
int loc=upper_bound(dp+1,dp+n+1,num[i])-dp;
dp[loc]=num[i];
}
printf("%d\n",lower_bound(dp+1,dp+n+1,dp[0])-(dp+1));
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
b[x]=i;
}
for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
num[i]=b[x];
}
solve();
return 0;
}