#arc173c. C - Not Median
C - Not Median
Score: points
问题陈述
给定一个整数序列 ,它是从 到 的一个排列。
对于每个 ,打印出满足以下所有条件的整数对 的最小值 。如果不存在这样的 ,则打印 -1
。
- 是奇数。
- 序列 的连续子序列 的中位数 不是 。
这里,对于长度为 (奇数)的整数序列 , 的中位数定义为将 排序后得到的序列 的第 个值。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a permutation of integers from to .
For each , print the minimum value of for a pair of integers that satisfies all of the following conditions. If no such exists, print -1
.
- is odd.
- The median of the contiguous subsequence of is not .
Here, the median of for an integer sequence of length (odd) is defined as the -th value of the sequence obtained by sorting in ascending order.
Constraints
- is a permutation of integers from to .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answers for in this order, separated by spaces.
Sample Input 1
5
1 3 5 4 2
Sample Output 1
3 3 3 5 3
For example, when , if we set , then is odd, and the median of is , which is not , so the conditions are satisfied. Thus, the answer is .
On the other hand, when , the median of for any of is . If we set , the median of is , which is not , so the conditions are satisfied. Thus, the answer is .
Sample Input 2
3
2 1 3
Sample Output 2
-1 3 3
When , no pair of integers satisfies the conditions.
Sample Input 3
14
7 14 6 8 10 2 9 5 4 12 11 3 13 1
Sample Output 3
5 3 3 7 3 3 3 5 3 3 5 3 3 3