刘辰雨 @ 2021-11-05 19:13:15
#include<bits/stdc++.h>
using namespace std;
int n , num[100005];
struct hh
{
int shu , on;
};
hh a[100005];
int x;
int main()
{
scanf("%d" , &n);
for(int i = 1 ; i<= n ; i++ )
{
scanf("%d" , &x);
num[i] = x;
}
for(int i = 1 ; i<= n ; i++ )
{
scanf("%d" , &a[i].shu);
a[i].shu = num[a[i].shu];//离散化
}
for(int i = n ; i>= 1 ; i-- )
{
int max = 0;
for(int j = i+1 ; j<= n ; j++ )
{
if(a[j].shu > a[i].shu)//比大小
{
if(a[j].on > max)max = a[j].on;
}
}
a[i].on = max+1;//状态转移
}//求最长上升子序列
printf("%d" , a[1].on);
return 0;
}