11430: CF102951 - C. LCS on Permutations
[Creator : ]
Description
You are given two permutations $a$ and $b$ of length $N\ (1≤N≤10^5)$. Determine the length of their longest common subsequence.
Input
Line 1: The single integer $N$
Line 2: $N$ space separated integers $a_1…a_N\ (1≤a_i≤N$ and $a_i≠a_j$ for all $1≤i<j≤N$)
Line 3: $N$ space separated integers $b_1…b_N\ (1≤b_i≤N$ and $b_i≠b_j$ for all $1≤i<j≤N$)
Output
A single integer: the answer to the above problem
Sample 1 Input
5
3 2 1 4 5
1 2 3 4 5
Sample 1 Output
3