eolymp
bolt
Try our new interface for solving problems
Problems

Number of elements in unimodal sequence

Number of elements in unimodal sequence

Sequence $a_i$ is called \textbf{unimodal} if there exists such index $p$ that $a_1 < a_2 < ... < a_p$ and $a_p > a_{p+1} > ... > a_n$. For the given value of $x$ find how many times it appears in array. \InputFile The first line contains the size of array $n$ and number of queries $q~(n, q \le 10^6)$. The next line contains $n$ positive integers that represent a unimodal sequence. Each of the next $q$ lines contains value of $x$. Numbers in array do not exceed $10^9$. \OutputFile For each value of $x$ print in a separate line the number of times it appears in array.
Time limit 2 seconds
Memory limit 128 MiB
Input example #1
6 4
1 5 7 8 5 1
8
1
9
5
Output example #1
1
2
0
2
Input example #2
5 3
10 9 6 3 1
1
2
3
Output example #2
1
0
1
Author Michael Medvediev