#P8664. [蓝桥杯 2018 省 A] 付账问题
[蓝桥杯 2018 省 A] 付账问题
Description
It is common for several people to go out for a meal together. But when it is time to pay the bill, disputes often arise.
Now there are people dining out, and their total spending is yuan. The -th person brought yuan. Fortunately, the total amount of money everyone brought is enough to pay the bill, but the question is: how much should each person pay?
To be fair, under the condition that the total amount paid is exactly , we want the standard deviation of the amounts each person pays to be as small as possible. Here we agree that the amount each person pays can be any non-negative real number, i.e., it does not have to be an integer multiple of 1 cent. You need to output the minimum possible standard deviation.
Introduction to standard deviation: standard deviation is the square root of the average of the squared differences between several numbers and their mean, and it is generally used to describe “how large the deviation is” among these numbers. Formally, let the amount paid by the -th person be yuan, then the standard deviation is $s=\sqrt{\frac{1}{n}\sum_{i=1}^n(b_i-\frac{1}{n}\sum_{i=1}^n b_i)}$.
Input Format
The first line contains two integers and .
The second line contains non-negative integers .
Output Format
Output to standard output.
Output the minimum standard deviation, rounded to decimal places.
It is guaranteed that adding or subtracting to the correct answer will not change the rounding result.
5 2333
666 666 666 666 666
0.0000
10 30
2 1 4 7 4 8 3 6 4 7
0.7928
Hint
Sample Explanation
- Everyone pays yuan, and the standard deviation is 0.
Data Specification
For of the testdata, all are equal.
For of the testdata, all non-zero are equal.
For of the testdata, .
For of the testdata, .
For all testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号