#ABC470E. 集中 / Concentration
集中 / Concentration
Problem Statement
Takahashi is playing a solitaire game similar to the memory-matching game.
There are cards. A number is written on the front of each card, and nothing is written on the back.
For each satisfying , there are exactly two cards on which is written. (The are pairwise distinct.)
Takahashi plays the game with these cards using the following procedure.
- Shuffle the cards and lay them out face down.
- Set life to and score to .
- Repeat the following until life becomes or there are no cards left on the table:
- Choose one face-down card on the table, turn it face up, and check the number written on it.
- Choose one face-down card on the table, turn it face up, and check the number written on it.
- If , remove those two cards from the table, and increase the score by .
- If , turn the two cards face down again, and decrease life by .
Find the expected value of the score at the end of the game when Takahashi acts optimally to maximize the score at the end of the game.
Below is a more formal description of the game.
- Takahashi knows the rules of this game described below.
- Takahashi knows the values of .
- Let be a sequence obtained by choosing a permutation of the length- sequence uniformly at random.
- Initially, Takahashi knows none of the values of . Once he learns the value of , he remembers it completely thereafter.
- Let life be , score be , and be . Takahashi always knows these values.
- Repeat the following until life becomes or becomes empty:
- Based on the information obtained up to this point, Takahashi chooses an element from , and calls it .
- The value of is revealed, and Takahashi learns it.
- Based on the information obtained up to this point (including the value of ), Takahashi chooses an element from , and calls it .
- The value of is revealed, and Takahashi learns it.
- If , remove and from , and add to the score.
- If , decrease life by .
- Takahashi acts optimally to maximize the expected value of the score at the end of the game.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $L$
$A_1$ $A_2$ $\dots$ $A_N$
Output
Output the answer.
Your output will be considered correct if its absolute or relative error from the true answer is at most .
3 2
1 2 3
3.8666666667
The game may proceed as follows, for example. To distinguish the six cards, let us call them A, B, C, D, E, F.
- Start the game with life and score .
- Turn card
Aface up. is written on it. - Turn card
Bface up. is written on it. - Since different numbers are written, turn both cards face down again, and decrease life by to .
- Turn card
Cface up. is written on it. - Turn card
Aface up. is written on it. - Since the same number is written, remove both cards from the table, and increase the score by to .
- Turn card
Dface up. is written on it. - Turn card
Eface up. is written on it. - Since different numbers are written, turn both cards face down again, and decrease life by to .
- Since life has become , the game ends. The score is .
Note that, immediately after turning card C face up in this sequence, Takahashi can make the choice of "turning face up card A, the other already-known card with written on it, based on the fact that was written on the front of card C."
5 2
2 3 5 7 101
17.8560846561
20 10
10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200
770.7122293087
相关
在下列比赛中: