#CCBCHBAHAI0000088. Trả lời Q truy vấn tần suất trên miền nhỏ
Trả lời Q truy vấn tần suất trên miền nhỏ
Answer Q Frequency Queries on a Small Domain
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given integers with , define
For each of queries , print . Precompute one frequency array and answer each query in .
Input
The first line contains and . The second line contains the array. The third line contains query values, all in .
Output
For each query, print its frequency on a separate line in query order.
Subtask
Subtask 1 (20 points): .
Subtask 2 (30 points): .
Subtask 3 (50 points): .
Example
Input
8 5
2 5 2 0 5 5 7 2
5 2 1 0 7
Output
3
3
0
1
1
Explanation
The result follows directly from the mathematical definition above.