P27060 [AtCoder] Key Stroke War
NOI
题目描述

Problem Description

In the current Paken club, a game called "Key Stroke War" is popular. There are $ N $ members in the Paken club, and from them, $ K $ $(2K \leq N)$ representative players will be selected for a tournament called "Key Stroke War".
Each member has a value called "key stroke power", and the key stroke power of member $ i $ is $ A_i $. There are no pairs of members with the same key stroke power.
Currently, the $ K $ members with the lowest key stroke power are selected as "candidate representatives".

As the captain of the Paken club, you can perform the following operation zero or more times:

  • Choose any member $ i $ who is a candidate representative and any member $ j $ who is not a candidate representative to compete.
  • Member $ i $ wins with probability $\frac{A_i}{A_i+A_j}$, and member $ j $ wins with probability $\frac{A_j}{A_i+A_j}$.
  • If member $ i $ wins, nothing happens.
  • If member $ j $ wins, member $ j $ becomes a new candidate representative, and member $ i $ is removed from the candidate representatives.

When you stop arranging competitions, the members who are candidate representatives at that time will become the representative players.
You want to maximize the sum of the key stroke powers of the representative players by conducting as few competitions as possible. What is the expected number of competitions needed to maximize the sum of the key stroke powers of the representative players when competitions are arranged to minimize the expected number of competitions?

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $
$ A_1 $ $ A_2 $ $ ... $ $ A_{N-1} $ $ A_N $

Output Format

Output the minimum expected number of competitions.
The answer will be considered correct if the absolute or relative error is within $ 10^{-9} $.

Sample Input and Output

Sample Input #1

2 142 8

Sample Output #1

1.190476190476

Sample Input #2

5 13 9 4 2 8

Sample Output #2

1.222222222222

Sample Input #3

10 520 3 9 5 8 1 100 32 7 2

Sample Output #3

5.723472222222

Notes/Hints

Constraints

  • All inputs are integers.
  • $2 \leq N \leq 10^5$
  • $1 \leq 2K \leq N$
  • $1 \leq A_i \leq 10^9$
  • $A_i \neq A_j (i \neq j)$
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 142 8
样例输出
1.190476190476