标签:cpp 离散 https vector 更新 ret href mes tps
#include <map>
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
const int MAXN = 1e5+5;
int a[MAXN],b[MAXN];
int main(){
int N;
scanf("%d",&N);
map<int,int>m;
m.clear();
for(int i=0;i<N;i++){
scanf("%d",&a[i]);
m[a[i]]=i+1;
}
for(int i=0;i<N;i++){
scanf("%d",&b[i]);
b[i]=m[b[i]];
}
vector<int>v;
v.push_back(b[0]);
for(int i=1;i<N;i++){
int l=0,r=v.size();
if(b[i]>v[v.size()-1])
v.push_back(b[i]);
else{
while(l<r){
int mid=(l+r)/2;
if(b[i]>v[mid])l=mid+1;
else r=mid;
}
v[l]=b[i];
}
}
printf("%d\n",v.size());
return 0;
}
标签:cpp 离散 https vector 更新 ret href mes tps
原文地址:https://www.cnblogs.com/Vagrant-ac/p/12244229.html