#P2249. 【深基13.例1】查找

【深基13.例1】查找

Problem Description

Input nn non-negative integers a1,a2,,ana_1, a_2, \dots, a_n that are non-decreasing (meaning each later number is not smaller than the previous one), and each does not exceed 10910^9. Then perform mm queries. For each query, an integer qq is given. You need to output the index of the first occurrence of this number in the sequence. If it is not found, output 1-1.

Input Format

The first line contains two integers nn and mm, representing the number of integers and the number of queries.

The second line contains nn integers, representing the numbers to be queried.

The third line contains mm integers, representing the query numbers. The indices start from 11.

Output Format

Output one line containing mm integers separated by spaces, representing the answers.

11 3
1 3 3 3 5 7 9 11 13 15 15
1 3 6
1 2 -1 

Hint

Constraints: 1n1061 \leq n \leq 10^6, 0ai,q1090 \leq a_i, q \leq 10^9, 1m1051 \leq m \leq 10^5.

The input and output size of this problem is large. Please use fast I/O methods.

Translated by ChatGPT 5