AtCoder Regular Contest 118
B
Village of M People
AtCoder
⌀ 1196
原题
← AC →
翻译中…

Problem Statement

翻译中…

The Republic of ARC has $N$ citizens, all of whom play competitive programming. Each citizen is given a dan (grade) which is $1$, $2$, $\ldots$, or $K$, according to their skill.

翻译中…

A national census has revealed that there are exactly $A_i$ citizens with dan $i$. To make this data easier to understand, the king has decided to describe the country as if it were a village of $M$ people.

翻译中…

Set the number of people with dan $i$ in the village, $B_i$, so that $\max_i\left|\frac{B_i}{M} - \frac{A_i}{N}\right|$ is minimized, while satisfying the following:

翻译中…
  • each $B_i$ is a non-negative integer, satisfying $\sum_{i=1}^K B_i = M$.
翻译中…

Print one such way to set $B = (B_1, B_2, \ldots, B_K)$.

翻译中…

Constraints

翻译中…
  • $1\leq K\leq 10^5$
  • $1\leq N, M\leq 10^9$
  • Each $A_i$ is a non-negative integer satisfying $\sum_{i=1}^K A_i = N$.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

K N M
A_1 A_2 \ldots A_K

翻译中…

Output

翻译中…

Print the elements in your integer sequence $B$ satisfying the requirement in one line, with spaces in between.

翻译中…

B_1 B_2 \ldots B_K

翻译中…

If multiple sequences satisfy the requirement, any of them will be accepted.

翻译中…

样例

Input #1
3 7 20
1 2 4
Output #1
3 6 11
In this output, we have $\max_i\left|\frac{B_i}{M} - \frac{A_i}{N}\right| = \max\left(\left|\frac{3}{20}-\frac{1}{7}\right|, \left|\frac{6}{20}-\frac{2}{7}\right|, \left|\frac{11}{20}-\frac{4}{7}\right|\right) = \max\left(\frac{1}{140}, \frac{1}{70}, \frac{3}{140}\right) = \frac{3}{140}$.
Input #2
3 3 100
1 1 1
Output #2
34 33 33
Note that $B_1 = B_2 = B_3 = 33$ does not satisfy the requirement, since the sum must be $M = 100$. In this sample, other than `34 33 33`, printing `33 34 33` or `33 33 34` will also be accepted.
Input #3
6 10006 10
10000 3 2 1 0 0
Output #3
10 0 0 0 0 0
Input #4
7 78314 1000
53515 10620 7271 3817 1910 956 225
Output #4
683 136 93 49 24 12 3
题目信息
题号
arc118_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。