atcoder#ABC304G. [ABC304G] Max of Medians
[ABC304G] Max of Medians
Score : points
Problem Statement
You are given a sequence of length : .
Find the maximum value that can be obtained as the median of the length- sequence $(A_1 \oplus A_2, A_3 \oplus A_4, \ldots, A_{2N-1} \oplus A_{2N})$ by rearranging the elements of the sequence .
Here, represents bitwise exclusive OR.
What is bitwise exclusive OR?
The bitwise exclusive OR of non-negative integers A and B, denoted as A \oplus B, is defined as follows:- The number at the 2^k position (k \geq 0) in the binary representation of A \oplus B is 1 if and only if exactly one of the numbers at the 2^k position in the binary representation of A and B is 1, and it is 0 otherwise.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
4
4 0 0 11 2 7 9 5
14
By rearranging as , we get $(A_1 \oplus A_2, A_3 \oplus A_4, A_5 \oplus A_6, A_7 \oplus A_8) = (5, 14, 15, 2)$, and the median of this sequence is . It is impossible to rearrange so that the median of $(A_1 \oplus A_2, A_3 \oplus A_4, A_5 \oplus A_6, A_7 \oplus A_8)$ is or greater, so we print .
1
998244353 1000000007
1755654
5
1 2 4 8 16 32 64 128 256 512
192