E. 博弈博弈博弈!

    Type: Default 1000ms 256MiB

博弈博弈博弈!

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

博弈博弈博弈!

题目描述

有一个正整数序列 aa,两人进行游戏,规则如下:

  • 当序列中只有一个元素时,游戏结束。
  • 否则,两人交替操作,每次需要选出 aa 中的两个元素 ai,aj(ij)a_i,a_j(i\ne j),将它们删除并插入一个值为 ai+aj22\lfloor\frac{a_i+a_j}{2}\rfloor\cdot 2 的元素。

先手希望使得最终 aa 中留下的数最大化,后手希望最小化,两人都按最优策略进行游戏。求对于给定的长为 nn 的序列 aa每个非空前缀,对该前缀进行游戏的结果,即最后留下的数。

输入格式

第一行一个正整数 nn,表示序列长度。

接下来 nn 个正整数,描述序列 aa

输出格式

输出一行表示所求的答案。

样例

Input 1

6
6 3 7 2 5 4

Output 1

6 8 16 18 22 26

Input 2

5
7 13 11 19 1

Output 2

7 20 30 48 50

Input 3

3
3 10 11

Output 3

3 12 24

提示说明

Constraints

子任务 nn\le 特殊性质 分值
11 55 N/A 2020
22 10510^5 aia_i 只有1 1010
33 ai2a_i\le 2 2020
44 100100 N/A 1010
55 10510^5 4040

ai109a_i\le 10^9


暴力、部分分训练

Not Attended
Status
Done
Rule
IOI
Problem
8
Start at
2024-10-6 14:00
End at
2024-10-6 18:00
Duration
4 hour(s)
Host
Partic.
4