No.3197 Frequency Counter
Problem Statement
You are given a sequence $A=(A_1,A_2,\dots ,A_N)$ consisting of $N$ integers.
Then, $Q$ queries are given. In the $i$-th query, $2$ integers $x_i$ and $k_i$ are given.
For each query, count the number of times the integer $x_i$ appears in the sequence $A$, and print Yes if that count is at least $k_i$, and No otherwise.
Input
$N$ $A_1\ A_2\ \dots\ A_N$ $Q$ $x_1\ k_1$ $x_2\ k_2$ $\dots$ $x_Q\ k_Q$
- $1\leq N,Q\leq 2\times 10^5$
- $1\leq A_i,x_i\leq 10^9$
- $1\leq k_i\leq N$
Output
Print the answers to the queries over $Q$ lines, separated by newlines.
Print a newline at the end.
Sample
Sample 1
Input
7 1 8 2 1 8 1 3 4 1 3 8 2 2 2 3 1
Output
Yes Yes No Yes
In the sequence $A$, 1 appears $3$ times, 8 appears $2$ times, 2 appears $1$ time, and 3 appears $1$ time.
- Query
1 3: the number of occurrences of1(3) is at least $k=3$, soYes. - Query
8 2: the number of occurrences of8(2) is at least $k=2$, soYes. - Query
2 2: the number of occurrences of2(1) is less than $k=2$, soNo. - Query
3 1: the number of occurrences of3(1) is at least $k=1$, soYes.
Sample 2
Input
10 3 1 4 1 5 9 2 6 5 3 5 6 1 7 1 8 1 9 1 10 1
Output
Yes No No Yes No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nauclhlt