Bigger Than X, in a Slice
Answer Q queries (l, r, x): how many elements of al..r are strictly greater than x? The array never changes.
Input: the first line has N and Q; the second line has the array; the next Q lines have l r x.
Output: one line per query.
Constraints:
- 1 ≤ N, Q ≤ 105
- |values|, |x| ≤ 106
Sample Tests
Input 1
5 2 1 5 2 4 3 1 3 1 2 5 3
Output 1
2 2
Input 2
1 1 7 1 1 7
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.