atcoder#ARC118B. [ARC118B] Village of M People

[ARC118B] Village of M People

Score : 400400 points

Problem Statement

The Republic of ARC has NN citizens, all of whom play competitive programming. Each citizen is given a dan (grade) which is 11, 22, \ldots, or KK, according to their skill.

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

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

  • each BiB_i is a non-negative integer, satisfying i=1KBi=M\sum_{i=1}^K B_i = M.

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

Constraints

  • 1K1051\leq K\leq 10^5
  • 1N,M1091\leq N, M\leq 10^9
  • Each AiA_i is a non-negative integer satisfying i=1KAi=N\sum_{i=1}^K A_i = N.

Input

Input is given from Standard Input in the following format:

KK NN MM

A1A_1 A2A_2 \ldots AKA_K

Output

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

B1B_1 B2B_2 \ldots BKB_K

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

3 7 20
1 2 4
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}$.

3 3 100
1 1 1
34 33 33

Note that B1=B2=B3=33B_1 = B_2 = B_3 = 33 does not satisfy the requirement, since the sum must be M=100M = 100.

In this sample, other than 34 33 33, printing 33 34 33 or 33 33 34 will also be accepted.

6 10006 10
10000 3 2 1 0 0
10 0 0 0 0 0
7 78314 1000
53515 10620 7271 3817 1910 956 225
683 136 93 49 24 12 3