muyang_233 @ 2019-09-28 15:16:35
RT 菜鸡太菜了,仍然调不对
#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 mnbvcxzlkjhgfdsapoiu @ 2019-09-28 15:19:26
@muyang_233 谁菜?
by disangan233 @ 2019-09-28 15:50:33
@muyang_233 qndcj
by muyang_233 @ 2019-09-28 15:56:14
@disangan233 神dsg又D人了 快帮我啊我太菜了