306682: CF1237A. Balanced Rating Changes

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Balanced Rating Changes

题意翻译

另一轮$Codeforces$比赛刚刚结束!!这场比赛一共有$n$个参与者,按照比赛结果和$Codeforce$的规矩,对于参与者$i$预估的评分变化为$a_i$,由于$Codeforce$的特色,这些评分变化需要符合**完美平衡** —— 即他们的**总和为**$0$. 不过有一些不好的事情发生了,由于一些轻微的技术故障,这场比赛只公开了**半评分**。这意味着所有的评分变化都需要被分成两个。 这里有两个条件: - 对于每个参与者$i$,他的最终评分变化$b_i$必须是一个整数,并且要尽可能接近$\frac{a_i}{2}$。这代表每一个 $b_i = \left \lfloor\dfrac{a_i}{2} \right \rfloor $或者$b_i = \left \lceil\dfrac{a_i}{2} \right \rceil $。特别的,如果$a_i$可以被评分,那么$b_i = \dfrac {a_i}{2}$。这里$\left \lfloor x \right \rfloor$表示取$\le x$的最大整数,而$\left \lceil x \right \rceil$则表示取$\ge x$的最大整数。 - 最终的评分变化一定是**完美平衡**的 —— 他们的总和为$0$。 那么你可以帮忙做这个嘛??? ------ 简洁题面: 现在给你一个$n$和$n$个整数$a_i $,现在处理每个$a_i$来得到$b_i$,按照以下规则: - $b_i = \left \lfloor\dfrac{a_i}{2} \right \rfloor$或者$b_i = \dfrac {a_i}{2}$. - 最终得到的所有$b_i$之和应该为$0$。 输出所有的$b_i$。 (本题包含$SPJ$) 翻译:littleseven [博客地址]([http://littleseven.top](http://littleseven.top/))

题目描述

Another Codeforces Round has just finished! It has gathered $ n $ participants, and according to the results, the expected rating change of participant $ i $ is $ a_i $ . These rating changes are perfectly balanced — their sum is equal to $ 0 $ . Unfortunately, due to minor technical glitches, the round is declared semi-rated. It means that all rating changes must be divided by two. There are two conditions though: - For each participant $ i $ , their modified rating change $ b_i $ must be integer, and as close to $ \frac{a_i}{2} $ as possible. It means that either $ b_i = \lfloor \frac{a_i}{2} \rfloor $ or $ b_i = \lceil \frac{a_i}{2} \rceil $ . In particular, if $ a_i $ is even, $ b_i = \frac{a_i}{2} $ . Here $ \lfloor x \rfloor $ denotes rounding down to the largest integer not greater than $ x $ , and $ \lceil x \rceil $ denotes rounding up to the smallest integer not smaller than $ x $ . - The modified rating changes must be perfectly balanced — their sum must be equal to $ 0 $ . Can you help with that?

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 2 \le n \le 13\,845 $ ), denoting the number of participants. Each of the next $ n $ lines contains a single integer $ a_i $ ( $ -336 \le a_i \le 1164 $ ), denoting the rating change of the $ i $ -th participant. The sum of all $ a_i $ is equal to $ 0 $ .

输出格式


Output $ n $ integers $ b_i $ , each denoting the modified rating change of the $ i $ -th participant in order of input. For any $ i $ , it must be true that either $ b_i = \lfloor \frac{a_i}{2} \rfloor $ or $ b_i = \lceil \frac{a_i}{2} \rceil $ . The sum of all $ b_i $ must be equal to $ 0 $ . If there are multiple solutions, print any. We can show that a solution exists for any valid input.

输入输出样例

输入样例 #1

3
10
-5
-5

输出样例 #1

5
-2
-3

输入样例 #2

7
-7
-29
0
3
24
-29
38

输出样例 #2

-3
-15
0
2
12
-15
19

说明

In the first example, $ b_1 = 5 $ , $ b_2 = -3 $ and $ b_3 = -2 $ is another correct solution. In the second example there are $ 6 $ possible solutions, one of them is shown in the example output.

Input

题意翻译

另一轮$Codeforces$比赛刚刚结束!!这场比赛一共有$n$个参与者,按照比赛结果和$Codeforce$的规矩,对于参与者$i$预估的评分变化为$a_i$,由于$Codeforce$的特色,这些评分变化需要符合**完美平衡** —— 即他们的**总和为**$0$. 不过有一些不好的事情发生了,由于一些轻微的技术故障,这场比赛只公开了**半评分**。这意味着所有的评分变化都需要被分成两个。 这里有两个条件: - 对于每个参与者$i$,他的最终评分变化$b_i$必须是一个整数,并且要尽可能接近$\frac{a_i}{2}$。这代表每一个 $b_i = \left \lfloor\dfrac{a_i}{2} \right \rfloor $或者$b_i = \left \lceil\dfrac{a_i}{2} \right \rceil $。特别的,如果$a_i$可以被评分,那么$b_i = \dfrac {a_i}{2}$。这里$\left \lfloor x \right \rfloor$表示取$\le x$的最大整数,而$\left \lceil x \right \rceil$则表示取$\ge x$的最大整数。 - 最终的评分变化一定是**完美平衡**的 —— 他们的总和为$0$。 那么你可以帮忙做这个嘛??? ------ 简洁题面: 现在给你一个$n$和$n$个整数$a_i $,现在处理每个$a_i$来得到$b_i$,按照以下规则: - $b_i = \left \lfloor\dfrac{a_i}{2} \right \rfloor$或者$b_i = \dfrac {a_i}{2}$. - 最终得到的所有$b_i$之和应该为$0$。 输出所有的$b_i$。 (本题包含$SPJ$) 翻译:littleseven [博客地址]([http://littleseven.top](http://littleseven.top/))

加入题单

算法标签: