Vus the Cossack has nn real numbers aiai. 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 bibi is either ⌊ai⌋⌊ai⌋ or ⌈ai⌉⌈ai⌉. In other words, bibi equals aiairounded 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 aiai is an integer, then there is no difference between ⌊ai⌋⌊ai⌋ and ⌈ai⌉⌈ai⌉, bibiwill always be equal to aiai.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer nn (1≤n≤1051≤n≤105) — the number of numbers.
Each of the next nn lines contains one real number aiai (|ai|<105|ai|<105). It is guaranteed that each aiai has exactly 55 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 00.
Output
In each of the next nn lines, print one integer bibi. For each ii, |ai−bi|<1|ai−bi|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4 4.58413 1.22491 -2.10517 -3.70387
Output
4 2 -2 -4
Input
5 -6.32509 3.30066 -0.93878 2.00000 1.96321
Output
-6 3 -1 2 2
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.
【题解】
先全部向下取整 得到的数加起来看是不是等于零 不是的话不是的话按顺序变 直到和等于0就ok了,他不是按照四舍五入来的
#include<cstdio>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
const int N = 1e5+10;
double a[N];
int b[N];
int main()
{
int n;
long long diff=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%lf",&a[i]);
b[i]=floor(a[i]);
diff+=b[i];
}
for(int i=1;i<=n&&diff<0;i++)
{
if(a[i]-b[i]<1e-6) continue;
diff++;
b[i]++;
}
for(int i=1;i<=n;i++)
printf("%d\n",b[i]);
return 0;
}