CF BUDDY
← Problems·

1237A · Balanced Rating Changes

1000 · implementation, math

Problem: 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=ai2b_i = \lfloor \frac{a_i}{2} \rfloor or bi=ai2b_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?

Input Format: The first line contains a single integer nn (2n138452 \le n \le 13\,845), denoting the number of participants.

Each of the next nn lines contains a single integer aia_i (336ai1164-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.

Output Format: 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=ai2b_i = \lfloor \frac{a_i}{2} \rfloor or bi=ai2b_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.

Note: 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.

Sample Cases

Case 1

Input

3
10
-5
-5

Output

5
-2
-3

Case 2

Input

7
-7
-29
0
3
24
-29
38

Output

-3
-15
0
2
12
-15
19

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback