Hide

Problem C
Plants

Languages en sv

Along a road that is $N$ meters long, there are $N$ plants. Plant $i$ is of species $A_i$ and is exactly one meter away from plant $A_{i-1}$. A botanist wants to walk along the road to collect plants. Since he has spent all his time in his lab, he is not in good shape, and therefore he asks you $Q$ questions of the form: if I want to collect all plants of the species between $0$ and $Q_i$, what is the minimum number of plants I need to pass by? He can start and end anywhere and can pass by a plant without collecting it.

Input

The first line contains two integers $N$ ($1 \leq N \leq 2 \cdot 10^5$) and $Q$ ($1 \leq Q \leq 2 \cdot 10^5$).

The second line contains $N$ integers, where the $i$-th integer $A_i$ ($0 \le A_i \le 10^9$) is the species of plant $i$.

Then follow $Q$ lines, each containing an integer $Q_i$ ($0 \leq Q_i \leq 10^9$) representing the $i$-th question the botanist asks you.

Output

Print $Q$ lines where the $i$-th line contains the answer to the $i$-th question. If it is impossible to collect plants between $0$ and $Q_i$, print $-1$.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

Group

Points

Constraints

$1$

$5$

$N, Q, A_i, Q_i \leq 200 $

$2$

$7$

$N \leq 200 $

$3$

$9$

$Q=1, Q_i=1$

$4$

$12$

All integers $A_i$ are different.

$5$

$16$

$N \leq 2000 $

$6$

$18$

$Q = 1$

$7$

$33$

No additional constraints.

Sample Input 1 Sample Output 1
5 5
0 0 1 3 2
2
3
4
1
0
4
4
-1
2
1
Sample Input 2 Sample Output 2
7 4
3 1 0 15 1 2 1
1
2
15
1000000000
2
4
-1
-1

Please log in to submit a solution to this problem

Log in