Search Game
Time limit2sMemory limit1024 MB
Find the query strategy that minimizes the expected score of locating a hidden X from 1 to N, where each query of up to K numbers reports how many are below X.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Prefix sum
- Solved
- No attempts yet
Problem
Jonghyeon, a student at KSA, made a search game to boost virtual currency trading at the autumn school festival. In the search game, an integer () is fixed before the game starts, and you find its value by asking the right questions. In each question, the player enters at most distinct positive integers not greater than . If is among the entered values, the game ends. Otherwise, the player receives the number of entered integers that are less than . This process repeats until the game ends. If the game takes questions, the final score is points. You are a hacker who wants to earn virtual currency and take all the snacks and souvenirs from Jonghyeon. Find the strategy that minimizes the expected score of the search game, and print that expected value. The value is fixed before the player enters anything, and the probability that is is .
Input
The first line contains two integers and , separated by a space. The second line contains integers , separated by spaces.
Output
Print the expected score under the optimal strategy, multiplied by .
Constraints
, , .