#P8113. Cirno's Persuasion Through Scoring

    ID: 21296 Type: Default 1000ms 256MiB

Cirno's Persuasion Through Scoring

Cirno's Persuasion Through Scoring

Cirno wants to show that a certain scoring mechanism can lead to unfair results. There are (n) residents and the platform has a maximum score (m). Each resident (i) has a psychological expected score (a_i) (an integer between 0 and (m), inclusive). However, when giving their score, a resident does not simply use (a_i). Instead, when it is a resident’s turn to score, if the current average on the platform is (A) and (A \gt a_i) (i.e. strictly greater than (a_i)), then the resident gives a score of (0) (complaining that the score is too high, and balancing it out). Otherwise (when (A \le a_i)), they give a full score of (m). Note that the initial average is 0.

Cirno is interested in the final platform average after all (n) residents have given their scores. By choosing different orders in which the residents rate, the final average can vary. Your task is to compute two numbers: the maximum possible final average and the minimum possible final average that can be achieved by some ordering of the residents’ scoring.

More formally, let the residents be permuted in an order. Initially, the platform average is (A_0=0). Then when a resident with expected score (a_i) votes, if the current average (A) is strictly greater than (a_i) (i.e. (A > a_i)), they give a score of (0); otherwise they give (m). The final average is the sum of the scores divided by (n).

All formulas are given in LaTeX format.

Determine the maximum and minimum final average scores possible.

inputFormat

The first line contains two integers (n) and (m) (the number of residents and the maximum score). The second line contains (n) integers (a_1,a_2,\dots,a_n) where (0 \le a_i \le m).

outputFormat

Output two numbers (floating‐point values) separated by a space: the maximum possible final average score and the minimum possible final average score. Your answer is considered correct if its absolute or relative error does not exceed (10^{-6}).

sample

2 10
0 10
10 5