Score : $500$ points
$2^N$ people, numbered $1$ to $2^N$, will participate in a rock-paper-scissors tournament.
The tournament proceeds as follows:
Here, if Person $i$ wins exactly $j$ games, they receive $C_{i,j}$ yen (Japanese currency). A person winning zero games receives nothing. Find the maximum possible total amount of money received by the $2^N$ people if the results of all games can be manipulated freely.
Input is given from Standard Input in the following format:
$N$ $C_{1,1}$ $C_{1,2}$ $\ldots$ $C_{1,N}$ $C_{2,1}$ $C_{2,2}$ $\ldots$ $C_{2,N}$ $\vdots$ $C_{2^N,1}$ $C_{2^N,2}$ $\ldots$ $C_{2^N,N}$
Print the answer.
2 2 5 6 5 2 1 7 9
15
The initial row of the people is $(1,2,3,4)$.
If Person $2$ wins the game against Person $1$, and Person $4$ wins the game against Person $3$, the row becomes $(2,4)$.
Then, if Person $4$ wins the game against Person $2$, the row becomes $(4)$, and the tournament ends.
Here, Person $2$ wins exactly $1$ game, and Person $4$ wins exactly $2$ games, so they receive $0+6+0+9=15$ yen in total, which is the maximum possible sum.
3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4