No.549 Material Synthesis System
Problem Statement
You are playing a social game called Yukicoder's Gate.
Yukicoder's Gate is an RPG in which you raise multiple androids.
You currently own $N$ androids, and their experience points are
$x_1, x_2, \dots, x_N$, respectively.
You want to combine these $N$ androids into one android using the synthesis system.
The details of the synthesis system are as follows.
- Let $a$ be the experience points of the material android, and $b$ be the experience points of the android being synthesized into
- The value of half of the material android's experience points, rounded down, is added to the experience points of the android being synthesized into
- That is, as a result of the synthesis, the experience points of the android being synthesized into become $b + \left \lfloor \frac{a}{2} \right \rfloor$
- The material android disappears
Find the maximum possible value of the experience points of the one android remaining at the end.
Input
$N$ $x_1$ $x_2$ ... $x_N$
The first line contains the number $N$ of androids you own.
The second line contains the experience points $x_i$ of each android, separated by single-byte spaces.
The constraints are as follows.
- $2 \leq N \leq 10^5$
- $1 \leq x_i \leq 10^4$
- All input values are integers
Output
Output the maximum possible value of the experience points of the one android remaining at the end.
Print a newline at the end.
Sample
Sample 1
Input
3 1 2 3
Output
4
In this case, performing the synthesis in the following order leaves an android with 4 experience points.
- Synthesizing android 2 into android 1 makes the experience points of android 1 equal to 2, and android 2 disappears
- The experience points of the remaining androids are 2, x, 3 (x indicates that the android has disappeared)
- Synthesizing android 1 into android 3 makes the experience points of android 3 equal to 4, and android 1 disappears
- The experience points of the remaining androids are x, x, 4, and the synthesis is now complete
Sample 2
Input
5 2 2 2 2 2
Output
6
In this case, repeating "synthesize android $i(>1)$ into android 1" leaves an android with 6 experience points, which is the maximum value.
Sample 3
Input
16 5 48 74 84 94 13 24 15 92 79 74 89 32 30 5 24
Output
435
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ