#539. 「Nowcoder多校 2019 Day1」Equivalent Prefixes
「Nowcoder多校 2019 Day1」Equivalent Prefixes
题目描述
Two arrays u and v each with m distinct elements are called equivalent if and only if for all where denotes the index of the minimum element among Since the array contains distinct elements, the definition of minimum is unambiguous.
Bobo has two arrays a and b each with n distinct elements. Find the maximum number where and are equivalent.
输入格式
The input consists of several test cases and is terminated by end-of-file. The first line of each test case contains an integer n. The second line contains n integers . The third line contains n integers .
- are distinct.
- are distinct.
- The sum of n does not exceed .
输出格式
For each test case, print an integer which denotes the result.
样例
样例输入
2
1 2
2 1
3
2 1 3
3 1 2
5
3 1 5 2 4
5 2 4 3 1
样例输出
1
3
4