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 aiai 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 aiai is an integer, then there is no difference between ⌊ai⌋⌊ai⌋ and ⌈ai⌉⌈ai⌉, bibi will 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

Copy
4
4.58413
1.22491
-2.10517
-3.70387
output

Copy
4
2
-2
-4
input

Copy
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
output

Copy
-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,现在让你进行向上或者向下取整,使得变化后的数组之和也是0

思路:把浮点型数组进行一种取整方式,然后把小数部分保留一下,看最后的小数部分的进行四舍五入后的结果,然后根据最后小数部分的和进行不断地进行改变取整方式就可以了

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
double a[maxn];
int b[maxn]; int main()
{
int n;
cin>>n;
double s=;
for(int t=;t<n;t++)
{
scanf("%lf",&a[t]);
b[t]=a[t];
s+=(a[t]-b[t]);
}
int ss=round(s);
if(ss>)
{ for(int t=;t<n;t++)
{
if(ss==)
{
break;
}
if(a[t]>b[t])
{
b[t]++;
ss--;
}
}
}
if(ss<)
{
for(int t=;t<n;t++)
{
if(ss==)
{
break;
}
if(a[t]<b[t])
{
b[t]--;
ss++;
}
}
}
for(int t=;t<n;t++)
{
cout<<b[t]<<endl;
} return ;
}

Codeforces Round #571 (Div. 2)-D. Vus the Cossack and Numbers的更多相关文章

  1. Codeforces Round #571 (Div. 2)

    A. Vus the Cossack and a Contest 签. #include <bits/stdc++.h> using namespace std; int main() { ...

  2. Vus the Cossack and Strings(Codeforces Round #571 (Div. 2))(大佬的位运算实在是太强了!)

    C. Vus the Cossack and Strings Vus the Cossack has two binary strings, that is, strings that consist ...

  3. Codeforces Round #552 (Div. 3) 题解

    Codeforces Round #552 (Div. 3) 题目链接 A. Restoring Three Numbers 给出 \(a+b\),\(b+c\),\(a+c\) 以及 \(a+b+c ...

  4. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

随机推荐

  1. H5移动端手势密码组件

    项目简介 最近参加了2017年360前端星计划,完成了一个有趣的UI组件开发大作业,借机和大家分享一下移动端开发的技术啦~~ 本项目采用原生JS和Canvas实现移动端手势密码组件,支持手势密码设置和 ...

  2. 前端面试基础题:Ajax原理

    Ajax 的原理简单来说是在⽤户和服务器之间加了—个中间层( AJAX 引擎),通过XmlHttpRequest 对象来向服务器发异步请求,从服务器获得数据,然后⽤ javascrip t 来操作 D ...

  3. 迭代列表不要For循环,这是Python列表推导式最基本的概念

    如果你还在使用 For 循环迭代列表,那么你需要了解了解列表推导式,看看它的基本概念都是什么. 列表解析式(List comprehension)或者称为列表推导式,是 Python 中非常强大和优雅 ...

  4. 如何利用Python在网上接单,兼职也能月薪过万

  5. Python3,逻辑运算符

    优先级 ()>not>and>or 1.or 在python中,逻辑运算符or,x or y, 如果x为True则返回x,如果x为False返回y值.因为如果x为True那么or运算 ...

  6. java 封装与this关键字

    一 封装 1.封装的概述 封装,它也是面向对象思想的特征之一.面向对象共有三个特征:封装,继承,多态. 封装表现: 1.方法就是一个最基本封装体. 2.类其实也是一个封装体. 从以上两点得出结论,封装 ...

  7. 2020-04-29:现在你有个秒杀抢购的app,用户不断大量增加,技术层面,你要怎么做

    2020-04-29:现在你有个秒杀抢购的app,用户不断大量增加,技术层面,你要怎么做,才能既满足用户需求,又能扛住压力,还能帮公司合理支出?福哥答案2020-04-29: 限流(杀部分用户祭天). ...

  8. win7蓝牙连接手机蓝牙

    今天有个需求,需要win7 PC连接手机蓝牙,并发送文件到手机端.在此记录下过程. 准备: win7 电脑主机. CSR 蓝牙dongle. 手机 1. 打开蓝牙服务 方法:打开控制面板,找到“管理工 ...

  9. 致敬学长!J20航模遥控器开源项目计划【开局篇】 | 先做一个开机界面 | MATLAB图像二值化 | Img2Lcd图片取模 | OLED显示图片

    我们的开源宗旨:自由 协调 开放 合作 共享 拥抱开源,丰富国内开源生态,开展多人运动,欢迎加入我们哈~ 和一群志同道合的人,做自己所热爱的事! 项目开源地址:https://github.com/C ...

  10. AOP计算方法执行时长

    AOP计算方法执行时长 依赖引入 <dependency> <groupId>org.springframework.boot</groupId> <arti ...