P3156 [Shenji 15. Example 1] Query Student ID Numbers
Description
There are $n(n \le 2 \times 10^6)$ students entering the classroom one after another. We know each student’s ID number (between $1$ and $10^9$), given in the order they enter the classroom. Class starts, and the teacher wants to know what the ID number of the $i$-th student who entered the classroom is (the first student to enter has $i=1$). The number of queries does not exceed $10^5$.
Input Format
The first line contains $2$ integers $n$ and $m$, representing the number of students and the number of queries.
The second line contains $n$ integers, representing the ID numbers in the order they enter the classroom.
The third line contains $m$ integers, representing queries asking for which student (by entry order) to check.
Output Format
Output $m$ integers as the answers, separated by newlines.
Explanation/Hint
Translated by ChatGPT 5