Frequency - MarisaOJ: Marisa Online Judge

Frequency

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers and $q$ queries, each of the form $(l, r, x)$, count the number of values which appear $x$ times in $A[l...r]$. ### Input - The first line contains 2 integers $n, q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines, each line contains 3 integers $l, r, x$, a query. ### Output - Print the answer for each query. ### Constraints - $1 \le n,q \le 10^5$. - $1 \le A_i \le 10^5$. ### Example Input: ``` 4 1 1 1 2 2 1 4 2 ``` Output: ``` 2 ```