#d11202. 最大连边数量
最大连边数量
Maximum Number of Edges
Problem Description
You are given two permutations and , each of length . All elements are in the range to .
You may draw an edge between and if and only if .
Find the maximum number of edges that can be drawn such that no two edges intersect (cross each other).
For example, in the sample, if is connected to and is connected to , then these two edges intersect.
It is guaranteed that both and are permutations.
Input Format
The first line contains an integer .
The next lines each contain one number .
The next lines each contain one number .
Sample Input
6
1
2
3
4
5
6
6
5
4
3
2
1
Sample Output
5
Constraints