USACO Guide Problem Submission |
---|
Finished |
You are given two permutations $$$a$$$ and $$$b$$$ of length $$$N$$$ ($$$1 \leq N \leq 10^5$$$). Determine the length of their longest common subsequence.
Line 1: The single integer $$$N$$$
Line 2: $$$N$$$ space separated integers $$$a_1 \dots a_N$$$ ($$$1 \leq a_i \leq N$$$ and $$$a_i \neq a_j$$$ for all $$$1 \leq i < j \leq N$$$)
Line 3: $$$N$$$ space separated integers $$$b_1 \dots b_N$$$ ($$$1 \leq b_i \leq N$$$ and $$$b_i \neq b_j$$$ for all $$$1 \leq i < j \leq N$$$)
A single integer: the answer to the above problem
5 3 2 1 4 5 1 2 3 4 5
3
One possible longest common subsequence would be $$$3, 4, 5$$$.
Name |
---|