영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
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 ≤ N ≤ 2 · 10^5) and Q (1 ≤ Q ≤ 2 · 10^5).
The second line contains N integers, where the i-th integer A_i (0 ≤ A_i ≤ 10^9) is the species of plant i.
Then follow Q lines, each containing an integer Q_i (0 ≤ Q_i ≤ 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 ≤ 200 |
| 2 | 7 | N ≤ 200 |
| 3 | 9 | Q=1, Q_i=1 |
| 4 | 12 | All integers A_i are different. |
| 5 | 16 | N ≤ 2000 |
| 6 | 18 | Q = 1 |
| 7 | 33 | No additional constraints. |
예제
예제 1
5 5 0 0 1 3 2 2 3 4 1 0
4 4 -1 2 1
예제 2
7 4 3 1 0 15 1 2 1 1 2 15 1000000000
2 4 -1 -1