Guessing Game
Time limit1sMemory limit256 MB
Identify a hidden integer from 1 to n with adaptive subset questions where each NO costs a and each YES costs b while minimizing the worst-case total.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Binary search, Math
- Solved
- No attempts yet
Problem
John and George play the following game. John picks one integer from the set , and George has to find out which integer it is. The game runs in moves . On move George picks a subset of , and John answers YES if belongs to and NO otherwise. For a NO answer George pays John euros, and for a YES answer he pays euros.
George hears each answer before he picks the next subset. Among all strategies that always identify , find the one whose largest possible total payment is smallest, and compute that payment.
Input
The first line contains three integers , , and , separated by spaces.
Output
Print one integer, the minimum amount of euros George has to pay.
Constraints
Hint
For , , George can find for 4 euros.
George first picks .
- If John answers YES, George pays 2 euros and picks . On another YES he pays 2 more euros and the game ends (). On NO he pays 1 more euro and the game ends ().
- If John answers NO, George pays 1 euro and picks . On YES he pays 2 more euros and the game ends (). On NO he pays 1 more euro and picks . On YES he pays 2 more euros and the game ends (). On NO he pays 1 more euro and the game ends ().
The most expensive outcomes are and , and both cost 4 euros.