题目描述:给定一个 1 至 2n−1 的排列 a1, a2, ⋅⋅⋅, a2n−1,定义:
bi,j={aj (i=n)f(bi+1,j, bi+1,j+1, bi+1,j+2) otherwise
其中 1≤i≤n,1≤j<2n,且 f(x,y,z) 代表 x,y,z 的中位数。求 b1,1 的值。
输入格式:第一行一个正整数,代表 n;第二行 2n−1 个整数,代表 a。
输出格式:一行一个正整数,代表 b1,1。
数据范围:1≤n≤105。
这里提供三组样例,应该能卡掉大部分的想法。
Input:
3
1 4 3 5 2
Output:
3
Explain:
3
3 4 3
1 4 3 5 2
Input:
4
3 1 2 4 5 6 7
Output:
4
Explain:
4
2 4 5
2 2 4 5 6
3 1 2 4 5 6 7
Input:
4
3 4 2 6 5 1 7
Output:
5
Explain:
5
4 5 5
3 4 5 5 5
3 4 2 6 5 1 7