#P2503. [HAOI2006] 均分数据
[HAOI2006] 均分数据
Description
Given positive integers . We want to partition them into groups so that the sums of the groups are as balanced as possible, i.e., the standard deviation of the group sums is minimized. The formula for the standard deviation is as follows:
$$\sigma = \sqrt{\frac 1m \sum\limits_{i=1}^m(\overline x - x_i)^2},\overline x = \frac 1m \sum\limits_{i=1}^m x_i$$Here, is the standard deviation, is the average of the group sums, and is the sum of the -th group.
Input Format
The first line contains two integers, representing the values of ( is the number of integers, and is the number of groups).
The second line contains integers, representing . Each integer is in the range .
Integers on the same line are separated by spaces.
Output Format
Output one real number on a single line, representing the minimal value of the standard deviation, rounded to two decimal places.
6 3
1 2 3 4 5 6
0.00
Hint
Sample explanation: group as , , .
Constraints
For of the testdata, it is guaranteed that , .
For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号