标签:org class 子序列 www scanf clu nbsp http namespace
https://www.luogu.org/problemnew/show/P1439
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int a[100001], b[100001], map[100001], pos[100001]; 5 int main(){ 6 int n; 7 cin>>n; 8 for(int i=1; i<=n; i++){ 9 scanf("%d",&a[i]); 10 map[a[i]]=i; 11 } 12 for(int i=1; i<=n; i++){ 13 scanf("%d",&b[i]); 14 pos[i]=0x7fffffff; 15 } 16 int len=0; 17 pos[0]=0; 18 for(int i=1; i<=n; i++){ 19 int l=0, r=len, mid; 20 if(map[b[i]]>pos[len]) pos[++len]=map[b[i]]; 21 else{ 22 while(l<r){ 23 mid=(l+r)/2; 24 if(pos[mid]>map[b[i]] ) r=mid; 25 else l=mid+1; 26 } 27 pos[l]=min(map[b[i]], pos[l]); 28 } 29 } 30 cout<<len<<endl; 31 return 0; 32 }
标签:org class 子序列 www scanf clu nbsp http namespace
原文地址:https://www.cnblogs.com/Aze-qwq/p/9337750.html