CF1237A.Balanced Rating Changes
入门
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Another Codeforces Round has just finished! It has gathered n participants, and according to the results, the expected rating change of participant i is ai. 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 bi must be integer, and as close to 2ai as possible. It means that either bi=⌊2ai⌋ or bi=⌈2ai⌉. In particular, if ai is even, bi=2ai. Here ⌊x⌋ denotes rounding down to the largest integer not greater than x, and ⌈x⌉ 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?
又一场 Codeforces 比赛刚刚结束!共有 n 名参赛者,根据比赛结果,第 i 位参赛者的预期评分为变化量为 ai。这些评分变化量是完全平衡的——它们的总和恰好为 0。
不幸的是,由于一些轻微的技术故障,本次比赛被定为“半评级”(semi-rated)。这意味着所有评分变化量都必须除以 2。
但需满足以下两个条件:
- 对于每位参赛者 i,其调整后的评分变化量 bi 必须为整数,且尽可能接近 2ai。即 bi 只能取 ⌊2ai⌋ 或 ⌈2ai⌉ 中的一个值。特别地,若 ai 是偶数,则 bi=2ai。其中 ⌊x⌋ 表示不超过 x 的最大整数(向下取整),⌈x⌉ 表示不小于 x 的最小整数(向上取整)。
- 调整后的评分变化量也必须完全平衡——它们的总和必须等于 0。
你能帮忙解决这个问题吗?
输入格式
The first line contains a single integer n (2≤n≤13845), denoting the number of participants.
Each of the next n lines contains a single integer ai (−336≤ai≤1164), denoting the rating change of the i-th participant.
The sum of all ai is equal to 0.
第一行包含一个整数 n(2≤n≤13845),表示参赛人数。
接下来的 n 行中,每行包含一个整数 ai(−336≤ai≤1164),表示第 i 位参赛者的评分变化量。
所有 ai 的总和等于 0。
输出格式
Output n integers bi, each denoting the modified rating change of the i-th participant in order of input.
For any i, it must be true that either bi=⌊2ai⌋ or bi=⌈2ai⌉. The sum of all bi must be equal to 0.
If there are multiple solutions, print any. We can show that a solution exists for any valid input.
输出 n 个整数 bi,其中每个 bi 表示按输入顺序排列的第 i 位参赛者的修改后评分变化值。
对于任意 i,必须满足 bi=⌊2ai⌋ 或 bi=⌈2ai⌉。所有 bi 的总和必须等于 0。
若存在多个解,输出任意一个即可。我们可以证明:对任意合法输入,解均存在。
输入输出样例
输入#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=5, b2=−3 and b3=−2 is another correct solution.
In the second example there are 6 possible solutions, one of them is shown in the example output.
在第一个例子中,b1=5、b2=−3 且 b3=−2 是另一个正确解。
在第二个例子中,共有 6 种可能的解,其中一种如示例输出所示。
输入解题思路,AI测评打分。不知道怎么写?