This problem is a Mooshak version of a SPOJ problem.
You will be given a sequence of \(n\) numbers \(a_1, a_2, \ldots, a_n\) and a number of k-queries in the form of a triple of integers \((i, j, k)\). For each of the queries, you have to return the number of elements greater than \(k\) in the subsequence \(a_i, a_{i+1}, \ldots, a_j\).
The first input line contains two integers \(n\) and \(q\): the size of the sequence and the number of queries.
The next line contains \(n\) integers \(a_1, a_2, \ldots, a_n\): the integers in the sequence.
The next \(q\) lines each contain a query in the form of three integers \(i \, j \, k\).
For each k-query \((i, j, k)\), print the number of elements greater than \(k\) in the subsequence \(a_i, a_{i+1}, \ldots, a_j\) in a single line.
Example Input | Example Output |
6 3 5 1 2 3 4 5 2 4 1 4 4 4 1 6 2 |
2 0 4 |