#P6332. Maximize the Minimum Distance to an Even Sequence
Maximize the Minimum Distance to an Even Sequence
Maximize the Minimum Distance to an Even Sequence
Given a sequence of n even integers \(p_1, p_2, \dots, p_n\) and two integers \(A\) and \(B\), find an odd integer \(X\) in the interval \([A, B]\) such that the value
\[ f(X)=\min_{1\le i\le n} |X-p_i| \]
is maximized. If there are multiple valid answers, output any one of them.
inputFormat
The first line contains three integers \(n\), \(A\) and \(B\) (with \(n\) being the number of elements in the even sequence). The second line contains \(n\) even integers \(p_1, p_2, \dots, p_n\) separated by spaces.
You can assume that there is at least one odd integer in the interval \([A, B]\).
outputFormat
Output a single odd integer \(X\) in the interval \([A, B]\) that maximizes \(f(X)=\min_{1\le i\le n}|X-p_i|\).
sample
4 1 9
2 4 6 8
1
</p>