CF BUDDY
← Problems·

1186D · Vus the Cossack and Numbers

1500 · constructive algorithms, greedy, math

Problem: Vus the Cossack has nn real numbers aia_i. It is known that the sum of all numbers is equal to 00. He wants to choose a sequence bb the size of which is nn such that the sum of all numbers is 00 and each bib_i is either ai\lfloor a_i \rfloor or ai\lceil a_i \rceil. In other words, bib_i equals aia_i rounded up or down. It is not necessary to round to the nearest integer.

For example, if a=[4.58413,1.22491,2.10517,3.70387]a = [4.58413, 1.22491, -2.10517, -3.70387], then bb can be equal, for example, to [4,2,2,4][4, 2, -2, -4].

Note that if aia_i is an integer, then there is no difference between ai\lfloor a_i \rfloor and ai\lceil a_i \rceil, bib_i will always be equal to aia_i.

Help Vus the Cossack find such sequence!

Input Format: The first line contains one integer nn (1n1051 \leq n \leq 10^5) — the number of numbers.

Each of the next nn lines contains one real number aia_i (ai<105|a_i| < 10^5). It is guaranteed that each aia_i has exactly 55 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 00.

Output Format: In each of the next nn lines, print one integer bib_i. For each ii, aibi<1|a_i-b_i|<1 must be met.

If there are multiple answers, print any.

Note: The first example is explained in the legend.

In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.

Sample Cases

Case 1

Input

4
4.58413
1.22491
-2.10517
-3.70387

Output

4
2
-2
-4

Case 2

Input

5
-6.32509
3.30066
-0.93878
2.00000
1.96321

Output

-6
3
-1
2
2

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