#C10456. Counting Greater Elements

    ID: 39663 Type: Default 1000ms 256MiB

Counting Greater Elements

Counting Greater Elements

This problem asks you to compute the number of elements in a subarray which are strictly greater than a given threshold. You are given an array \(a_1, a_2, \ldots, a_n\) and \(q\) queries. Each query is represented by three integers \(l\), \(r\), and \(k\). For each query, you must count the number of indices \(i\) (with \(l \leq i \leq r\)) for which the inequality \(a_i > k\) holds.

Input Format: The first line contains two integers \(n\) and \(q\) — the number of elements in the array and the number of queries. The second line contains \(n\) space-separated integers representing the array. The following \(q\) lines contain three integers each: \(l\), \(r\), and \(k\), describing one query.

Output Format: For each query, output a single line with the answer to that query.

inputFormat

The first line contains two integers \(n\) and \(q\), where \(n\) is the number of integers in the array and \(q\) is the number of queries. The second line contains \(n\) space-separated integers denoting the array elements \(a_1, a_2, \dots, a_n\). Each of the next \(q\) lines contains three integers \(l\), \(r\), and \(k\) indicating a query. Note that the array is 1-indexed.

outputFormat

For each query, output a single integer on a separate line representing the count of elements greater than \(k\) in the subarray from index \(l\) to \(r\) (inclusive).

## sample
5 3
1 3 5 7 9
1 3 4
2 5 6
1 5 8
1

2 1

</p>