eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Grey Area

Grey Area

Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. \includegraphics{https://static.e-olymp.com/content/12/12c1c2d9d5ee78acc47cde12fda040ff51eae008.jpg} \textit{\textbf{Figure 1}}: A histogram \textit{\textbf{Figure 1}} is an example of histogram automatically produced by his histogram generator. A histogram is a visual display of frequencies of value occurrences as bars. In this example, values in the interval \textbf{0--9} occur five times, those in the interval \textbf{10--19} occur three times, and \textbf{20--29} and \textbf{30--39} once each. Dr. Grey’s histogram generator is a simple tool. First, the height of the histogram is fixed, that is, the height of the highest bar is always the same and those of the others are automatically adjusted proportionately. Second, the widths of bars are also fixed. It can only produce a histogram of uniform intervals, that is, each interval of a histogram should have the same width (\textbf{10} in the above example). Finally, the bar for each interval is painted in a grey color, where the colors of the leftmost and the rightmost intervals are black and white, respectively, and the darkness of bars monotonically decreases at the same rate from left to right. For instance, in \textit{\textbf{Figure 1}}, the darkness levels of the four bars are \textbf{1}, \textbf{2/3}, \textbf{1/3}, and \textbf{0}, respectively. In this problem, you are requested to estimate ink consumption when printing a histogram on paper. The amount of ink necessary to draw a bar is proportional to both its area and darkness. \InputFile The input consists of multiple datasets, each of which contains integers and specifies a value table and intervals for the histogram generator, in the following format. \textbf{n w} \textbf{v_1} \textbf{v_2} \textbf{...} \textbf{v_n} \textbf{n} is the total number of value occurrences for the histogram, and each of the \textbf{n} lines following the first line contains a single value. Note that the same value may possibly occur multiple times. \textbf{w} is the interval width. A value \textbf{v} is in the first (i.e. leftmost) interval if \textbf{0} ≤ \textbf{v} < \textbf{w}, the second one if \textbf{w} ≤ \textbf{v} < \textbf{2w}, and so on. Note that the interval from \textbf{0} (inclusive) to \textbf{w} (exclusive) should be regarded as the leftmost even if no values occur in this interval. The last (i.e. rightmost) interval is the one that includes the largest value in the dataset. You may assume the following. \textbf{1} ≤ \textbf{n} ≤ \textbf{100} \textbf{10} ≤ \textbf{w} ≤ \textbf{50} \textbf{0} ≤ \textbf{v_i} ≤ \textbf{100} for \textbf{1} ≤ \textbf{i} ≤ \textbf{n} You can also assume that the maximum value is no less than \textbf{w}. This means that the histogram has more than one interval. The end of the input is indicated by a line containing two zeros. \OutputFile For each dataset, output a line containing the amount of ink consumed in printing the histogram. One unit of ink is necessary to paint one highest bar black. Assume that \textbf{0.01} units of ink per histogram is consumed for various purposes except for painting bars such as drawing lines and characters (see \textit{\textbf{Figure 1}}). For instance, the amount of ink consumed in printing the histogram in \textit{\textbf{Figure 1}} is: \includegraphics{https://static.e-olymp.com/content/c9/c9b7ae30661edc3aa3a1c97841b45403e59d0f21.jpg} Each output value should be in a decimal fraction and may have an error less than \textbf{10^\{−5\}}.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
3 
-20 -20 -24 
100 100 100 30 
10 8 3 5 
-70 -70 -84 5 
4 
0 47 84 
-23 41 42 8 
45 -10 14 19 
-5 28 47 12 
-27 68 34 14 
0
Выходные данные #1
79.0940 79.0940 94.9128 
-21.8647 54.9770 34.1761
Источник Asia Regional Contest, Japan, AIZU, October 25-27, 2008