CF1237A.Balanced Rating Changes

入门

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Another Codeforces Round has just finished! It has gathered nn participants, and according to the results, the expected rating change of participant ii is aia_i. These rating changes are perfectly balanced — their sum is equal to 00.

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 ii, their modified rating change bib_i must be integer, and as close to ai2\frac{a_i}{2} as possible. It means that either bi=⌊ai2⌋b_i = \lfloor \frac{a_i}{2} \rfloor or bi=⌈ai2⌉b_i = \lceil \frac{a_i}{2} \rceil. In particular, if aia_i is even, bi=ai2b_i = \frac{a_i}{2}. Here ⌊x⌋\lfloor x \rfloor denotes rounding down to the largest integer not greater than xx, and ⌈x⌉\lceil x \rceil denotes rounding up to the smallest integer not smaller than xx.
  • The modified rating changes must be perfectly balanced — their sum must be equal to 00.

Can you help with that?

又一场 Codeforces 比赛刚刚结束!共有 nn 名参赛者,根据比赛结果,第 ii 位参赛者的预期评分为变化量为 aia_i。这些评分变化量是完全平衡的——它们的总和恰好为 00。

不幸的是,由于一些轻微的技术故障,本次比赛被定为“半评级”(semi-rated)。这意味着所有评分变化量都必须除以 22。

但需满足以下两个条件:

  • 对于每位参赛者 ii,其调整后的评分变化量 bib_i 必须为整数,且尽可能接近 ai2\frac{a_i}{2}。即 bib_i 只能取 ⌊ai2⌋\lfloor \frac{a_i}{2} \rfloor 或 ⌈ai2⌉\lceil \frac{a_i}{2} \rceil 中的一个值。特别地,若 aia_i 是偶数,则 bi=ai2b_i = \frac{a_i}{2}。其中 ⌊x⌋\lfloor x \rfloor 表示不超过 xx 的最大整数(向下取整),⌈x⌉\lceil x \rceil 表示不小于 xx 的最小整数(向上取整)。
  • 调整后的评分变化量也必须完全平衡——它们的总和必须等于 00。

你能帮忙解决这个问题吗?

输入格式

The first line contains a single integer nn (2≤n≤13 8452 \le n \le 13\,845), denoting the number of participants.

Each of the next nn lines contains a single integer aia_i (−336≤ai≤1164-336 \le a_i \le 1164), denoting the rating change of the ii-th participant.

The sum of all aia_i is equal to 00.

第一行包含一个整数 nn(2≤n≤13 8452 \le n \le 13\,845),表示参赛人数。

接下来的 nn 行中,每行包含一个整数 aia_i(−336≤ai≤1164-336 \le a_i \le 1164),表示第 ii 位参赛者的评分变化量。

所有 aia_i 的总和等于 00。

输出格式

Output nn integers bib_i, each denoting the modified rating change of the ii-th participant in order of input.

For any ii, it must be true that either bi=⌊ai2⌋b_i = \lfloor \frac{a_i}{2} \rfloor or bi=⌈ai2⌉b_i = \lceil \frac{a_i}{2} \rceil. The sum of all bib_i must be equal to 00.

If there are multiple solutions, print any. We can show that a solution exists for any valid input.

输出 nn 个整数 bib_i,其中每个 bib_i 表示按输入顺序排列的第 ii 位参赛者的修改后评分变化值。

对于任意 ii,必须满足 bi=⌊ai2⌋b_i = \left\lfloor \frac{a_i}{2} \right\rfloor 或 bi=⌈ai2⌉b_i = \left\lceil \frac{a_i}{2} \right\rceil。所有 bib_i 的总和必须等于 00。

若存在多个解,输出任意一个即可。我们可以证明:对任意合法输入,解均存在。

输入输出样例

  • 输入#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, b1=5b_1 = 5, b2=−3b_2 = -3 and b3=−2b_3 = -2 is another correct solution.

In the second example there are 66 possible solutions, one of them is shown in the example output.

在第一个例子中,b1=5b_1 = 5、b2=−3b_2 = -3 且 b3=−2b_3 = -2 是另一个正确解。

在第二个例子中,共有 66 种可能的解,其中一种如示例输出所示。

输入解题思路,AI测评打分。不知道怎么写?

首页