P1918 Bowling

Description

DL is tired of fortune-telling, so he often goes to the gym to bowl for fun. Since he has been bowling for decades, technique is not a problem, and he wants to try something new. DL’s eyesight is really good. He can actually count the number of pins at each spot about ten meters ahead of him. He suddenly realizes this is a chance to show off—after seeing the exact number of pins at each position, he throws from a certain position so that he can knock down a certain number of pins. 1. ○ ○ ○ 2. ○ ○ ○ ○ 3. ○ 4. ○ ○ As shown above, each “○” represents one pin. If DL wants to knock down $3$ pins, he throws from position $1$; if he wants to knock down $4$ pins, he throws from position $2$. Now he wants to knock down $m$ pins. He tells you the number of pins at each position. Please give him a throwing position.

Input Format

The first line contains a positive integer $n$, the number of positions. The second line contains $n$ positive integers $a_i$, where $a_i$ is the number of pins at position $i$. It is guaranteed that the numbers of pins at all positions are distinct. The third line contains a positive integer $Q$, the number of DL’s throws. From the fourth line to the end of file, each line contains a positive integer $m$, the number of pins DL wants to knock down.

Output Format

Output $Q$ lines. Each line contains one integer: the position of DL’s $i$-th throw. If there is no solution, output $0$.

Explanation/Hint

Constraints For $50\%$ of the testdata, $1 \leq n, Q \leq 1000, 1 \leq a_i, m \leq 10^5$. For $100\%$ of the testdata, $1 \leq n,Q \leq 100000, 1 \leq a_i, m \leq 10^9$. Translated by ChatGPT 5