atcoder#RELAY2J. Indifferent
Indifferent
Score : points
Problem Statement
We have pots. The market price of the -th pot is yen (the currency of Japan).
Now, you and Lunlun the dachshund will alternately take one pot. You will go first, and we will continue until all the pots are taken by you or Lunlun. Since Lunlun does not know the market prices of the pots, she will always choose a pot randomly from the remaining pots with equal probability. You know this behavior of Lunlun, and the market prices of the pots.
Let the sum of the market prices of the pots you take be yen. Your objective is to maximize the expected value of . Find the expected value of when the optimal strategy is adopted.
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the expected value of when the strategy to maximize the expected value of is adopted. The output is considered correct if its absolute or relative error from the judge's output is at most .
1
150000
108
150000.0
Naturally, you should choose the yen pot.
2
50000
50000
100000
100000
183333.3333333333
First, you will take one of the yen pots. The other yen pot will become yours if it is not taken in Lunlun's next turn, with probability . If it is taken, you will have to settle for a yen pot. Thus, the expected value of when the optimal strategy is adopted is $2/3 \times (100000 + 100000) + 1/3 \times (100000 + 50000) = 183333.3333 \cdots$