No.699 Let's Form Teams in Pairs 2
タグ : / 解いたユーザー数 100
作問者 :
nmnmnmnmnmnmnm
Problem Statement
$N$ players ($N$ is even) form one team and take on some kind of battle.
The combat power of the $i$-th player is $A_i$.
Each of the $N$ players must form a pair of 2 people.
When a pair is formed, its combat power is the value obtained by adding the combat powers of its players.
The XOR of the combat powers of all pairs is the combat power of the team.
What is the maximum combat power of the team when the pairs are chosen optimally?
Input
$N$
$A_0$ $A_1$ $\dots$ $A_{N-1}$
$N$ is a positive integer ($N$ is even). $2 \le N \le 14$.
$A_i$ is a positive integer. $1 \le A_i \le 1000000000=10^9$.
Output
Output the answer on one line.
Print a newline at the end.
Sample
Sample 1
Input
4 1 2 3 4
Output
4
If the player with combat power 1 and the player with combat power 2 form a pair, the combat power of the pair is 3.
If the player with combat power 3 and the player with combat power 4 form a pair, the combat power of the pair is 7.
In this case, the combat power of the team is the XOR of the combat powers of the pairs, which is 4, and this is the maximum.
Sample 2
Input
4 1 1 1 1
Output
0
No matter how the pairs are formed, the combat power of the team is 0.
Forming pairs may result in a combat power lower than that of the individual players.
However, the pairs must be formed.
Sample 3
Input
10 387 137 192 123 29 193 753 210 821 437
Output
2044
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。