atcoder#AGC053B. [AGC053B] Taking the middle
[AGC053B] Taking the middle
Score : points
Problem Statement
We have cards, with ID numbers from through . Card has a value of . Takahashi and Aoki will do the following procedure times so that each of them gets cards.
- First, Takahashi chooses one card that is not yet chosen and gets it. Then, Aoki chooses the card whose ID number is the median of those of the cards not yet chosen and gets it.
Find the maximum possible sum of the values of cards Takahashi has in the end.
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 2 3 4 5 6
15
Takahashi can get Cards , , and as follows:
- First, Takahashi chooses Card , which makes Aoki choose Card .
- Next, Takahashi chooses Card , which makes Aoki choose Card .
- Lastly, Takahashi chooses Card , which makes Aoki choose Card .
4
1 4 5 8 7 6 3 2
20