#abc355g. G - Baseball

G - Baseball

Score : 650650 points

问题陈述

你得到了一个长度为 NN 的序列 P=(P1,P2,,PN)P=(P_1,P_2,\dots,P_N)。高桥和青木将使用序列 PP 进行一场游戏。

首先,高桥将从 1,2,,N1,2,\dots,N 中选择 KK 个不同的整数 x1,x2,,xKx_1,x_2,\dots,x_K

接下来,青木将从 1,2,,N1,2,\dots,N 中选择一个整数 yy,选择的概率与 PyP_y 成正比。也就是说,选择整数 yy 的概率是 Pyy=1NPy\dfrac{P_y}{\sum_{y'=1}^N P_{y'}}。然后,青木的得分将是 mini=1,2,,Kxiy\displaystyle \min_{i=1,2,\dots,K} |x_i-y|

高桥想要 最小化 青木得分的期望值。当高桥选择 x1,x2,,xKx_1,x_2,\dots,x_K 使得这个值最小化时,找出青木得分的期望值,乘以 y=1NPy\sum_{y'=1}^N P_{y'}。保证要打印的值是一个整数。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given a sequence P=(P1,P2,,PN)P=(P_1,P_2,\dots,P_N) of length NN. Takahashi and Aoki will play a game using the sequence PP.

First, Takahashi will choose KK distinct integers x1,x2,,xKx_1,x_2,\dots,x_K from 1,2,,N1,2,\dots,N.

Next, Aoki will choose an integer yy from 1,2,,N1,2,\dots,N with a probability proportional to PyP_y. That is, the probability that integer yy is chosen is Pyy=1NPy\dfrac{P_y}{\sum_{y'=1}^N P_{y'}}. Then, Aoki's score will be mini=1,2,,Kxiy\displaystyle \min_{i=1,2,\dots,K} |x_i-y|.

Takahashi wants to minimize the expected value of Aoki's score. Find the expected value of Aoki's score when Takahashi chooses x1,x2,,xKx_1,x_2,\dots,x_K so that this value is minimized, multiplied by y=1NPy\sum_{y'=1}^N P_{y'}. It is guaranteed that the value to be printed is an integer.

Constraints

  • 1N5×1041 \leq N \leq 5 \times 10^4
  • 1KN1 \leq K \leq N
  • 0Pi1050 \leq P_i \leq 10^5
  • 1y=1NPy1051 \leq \sum_{y'=1}^N P_{y'} \leq 10^5
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN KK

P1P_1 P2P_2 \dots PNP_N

Output

Print the answer.

Sample Input 1

5 2
1 1 1 1 1

Sample Output 1

3

The probabilities of Aoki choosing 1,2,,N1,2,\dots,N are all equal: 15\frac{1}{5}.

If Takahashi chooses x1=2x_1=2 and x2=4x_2=4, then the expected value of Aoki's score will be $1 \times \frac{1}{5} + 0 \times \frac{1}{5} + 1 \times \frac{1}{5} + 0 \times \frac{1}{5} + 1 \times \frac{1}{5} = \frac{3}{5}$.

If Takahashi chooses x1=2x_1=2 and x2=3x_2=3, then the expected value of Aoki's score will be $1 \times \frac{1}{5} + 0 \times \frac{1}{5} + 0 \times \frac{1}{5} + 1 \times \frac{1}{5} + 2 \times \frac{1}{5} = \frac{4}{5}$.

No matter how Takahashi chooses, the expected value of Aoki's score cannot be smaller than 35\frac{3}{5}. Therefore, the minimum value is 35\frac{3}{5}, so print this value multiplied by 55, which is 33.

Sample Input 2

5 1
0 0 1 0 0

Sample Output 2

0

Sample Input 3

1 1
100

Sample Output 3

0

Sample Input 4

20 7
4262 9522 2426 3823 7364 964 2743 2423 1955 5274 3684 847 363 35 278 3220 203 2904 6304 1928

Sample Output 4

22809