#C12889. Normalization of Values

    ID: 42365 Type: Default 1000ms 256MiB

Normalization of Values

Normalization of Values

This problem asks you to normalize a list of integers. Normalization means converting the values into a range of [0, 1]. The normalization is done using the formula:

$$x' = \frac{x - \min(x)}{\max(x) - \min(x)}$$

If the list is empty, output an empty result. If all elements in the list are identical, then every normalized value should be 0.5.

You will be given a number n (indicating the number of integers) followed by n space separated integers. Your task is to output the normalized values in the same order, separated by a space.

inputFormat

The first line of input is an integer n representing the number of elements.

If n > 0, the second line contains n space-separated integers.

If n is 0, there will be no second line and you should output an empty line.

outputFormat

If the input list is empty, output an empty line.

Otherwise, output a single line containing n space-separated floating-point numbers representing the normalized values. Use the normalization formula:

$$x' = \frac{x - \min(x)}{\max(x) - \min(x)}$$

In the case where all the input values are the same, output 0.5 for each element.

## sample
0