The Big Prize
문제
The Big Prize is a famous TV game show. You are the lucky contestant who has advanced to the final round. You are standing in front of a row of boxes, labeled through from left to right. Each box contains a prize that cannot be seen until the box is opened. There are different types of prizes. The types are numbered from to in decreasing order of value.
The prize of type is the most expensive one: a diamond. There is exactly one diamond in the boxes. The prize of type is the cheapest one: a lollipop. To make the game more exciting, the number of cheaper prizes is much larger than the number of more expensive ones. More specifically, for all such that we know the following: if there are prizes of type , there are strictly more than prizes of type .
Your goal is to win the diamond. At the end of the game you will have to open a box and you will receive the prize it contains. Before having to choose the box to open you get to ask Rambod, the host of the game show, some questions. For each question, you choose some box . As his answer, Rambod will give you an array containing two integers. Their meaning is as follows:
- Among the boxes to the left of box there are exactly boxes that contain a more expensive prize than the one in box .
- Among the boxes to the right of box there are exactly boxes that contain a more expensive prize than the one in box .
For instance, suppose that . For your question, you choose the box . As his response, Rambod tells you that . The meaning of this response is:
- Exactly one of the boxes and contains a prize more expensive than the one in box .
- Exactly two of the boxes contain a prize more expensive than the one in box .
Your task is to find the box containing the diamond by asking a small number of questions.