muyang_233 @ 2019-09-20 21:28:59
RT,窝真的是菜的不能再菜了
wzbl
QAQ
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int k;
int ans;
int a[100005];
int b[100005];
int dp[100005];
int last[100005];
int main(){
memset(last,0x3f,sizeof(last));
scanf("%d",&n);
for (int i=1;i<=n;i++){
int k;
scanf("%d",&k);
a[k]=i;
}
for (int i=1;i<=n;i++){
int k;
scanf("%d",&k);
b[k]=a[k];
}
k=1;
dp[1]=1;
last[1]=b[1];
for (int i=2;i<=n;i++){
int x=lower_bound(last+1,last+k+1,b[i])-last-1;
dp[i]=x+1;
last[x+1]=min(last[x+1],b[i]);
k=max(k,x+1);
}
for (int i=2;i<=n;i++){
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
return 0;
}
by ⚡小林孑⚡ @ 2019-09-20 21:34:14
@muyang_233 Orz %%%
by muyang_233 @ 2019-09-20 21:35:37
@脱发自动机 Orz%%% zws假假
by supinrui @ 2019-11-01 19:51:00
。。。