Vus the Cossack and Numbers
先令 。
由于 且 ,所以有 。
可以发现将一个非整数 从 变成 会使得总和增加 。所以可以将 个非整数 从 变成 。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int N = 1e5 + 5;
int n;
double a[N];
bool v[N];
int main()
{
scanf("%d", &n);
long long sum = 0;
for (int i = 1; i <= n; i++)
{
scanf("%lf", &a[i]);
v[i] = ((int)a[i]) == a[i];
a[i] = floor(a[i]);
sum += a[i];
}
long long need = 0 - sum;
for (int i = 1; i <= n; i++)
{
if (v[i] || need == 0)
{
printf("%.0f\n", a[i]);
continue;
}
printf("%.0f\n", a[i] + 1);
need--;
}
return 0;
}

浙公网安备 33010602011771号