#K7941. Normalization of Scores

    ID: 35302 Type: Default 1000ms 256MiB

Normalization of Scores

Normalization of Scores

You are given a target integer T and scores of n players. The goal is to scale each player's score so that the total sum of scores becomes exactly T, while keeping the relative proportions of the original scores.

For each player with score s_i, the unrounded normalized score is computed as:

\(s_i' = s_i \times \frac{T}{\sum_{i=1}^{n} s_i}\)

After computing the unrounded values, each score should be rounded to two decimal places. Due to rounding, the sum of the rounded scores might not equal exactly T. In such a case, adjust the first score by adding the difference so that the final sum equals T. It is guaranteed that the total of the original scores is non-zero.

Note: Use stdin to read input and stdout to output the result. The output should be the normalized scores separated by a single space, each printed with exactly two decimals.

inputFormat

The input is given in two lines:

  • The first line contains two integers: the target sum T and the number of players n.
  • The second line contains n integers representing the original scores of the players, separated by spaces.

outputFormat

Output the normalized scores as n floating-point numbers, each rounded to exactly two decimal places. The scores should be printed in the same order as the input, separated by a single space, and their sum must equal the target T.

## sample
100 4
10 20 30 40
10.00 20.00 30.00 40.00