{"problem":{"name":"Tournament","description":{"content":"$2^N$ people, numbered $1$ to $2^N$, will participate in a rock-paper-scissors tournament. The tournament proceeds as follows: *   The participants are arranged in a row in the order Person $1$, Pers","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc263_f"},"statements":[{"statement_type":"Markdown","content":"$2^N$ people, numbered $1$ to $2^N$, will participate in a rock-paper-scissors tournament.\nThe tournament proceeds as follows:\n\n*   The participants are arranged in a row in the order Person $1$, Person $2$, $\\ldots$, Person $2^N$ from left to right.\n*   Let $2M$ be the current length of the row. For each $i\\ (1\\leq i \\leq M)$, the $(2i-1)$\\-th and $(2i)$\\-th persons from the left play a game against each other. Then, the $M$ losers are removed from the row. This process is repeated $N$ times.\n\nHere, 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.\n\n## Constraints\n\n*   $1 \\leq N \\leq 16$\n*   $1 \\leq C_{i,j} \\leq 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ \n$C_{1,1}$ $C_{1,2}$ $\\ldots$ $C_{1,N}$\n$C_{2,1}$ $C_{2,2}$ $\\ldots$ $C_{2,N}$\n$\\vdots$\n$C_{2^N,1}$ $C_{2^N,2}$ $\\ldots$ $C_{2^N,N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc263_f","tags":[],"sample_group":[["2\n2 5\n6 5\n2 1\n7 9","15\n\nThe initial row of the people is $(1,2,3,4)$.\nIf Person $2$ wins the game against Person $1$, and Person $4$ wins the game against Person $3$, the row becomes $(2,4)$.\nThen, if Person $4$ wins the game against Person $2$, the row becomes $(4)$, and the tournament ends.\nHere, 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\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1","4"]],"created_at":"2026-03-03 11:01:14"}}