Count Negatives in a Range
Answer Q independent queries on a fixed array: each query gives L and R (1-based, inclusive) and asks for the number of strictly negative values of aL..R.
Input: the first line has N and Q; the second line has N integers; each of the next Q lines has L and R.
Output: Q lines — the answer per query.
Constraints:
- 1 ≤ N, Q ≤ 104
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
5 2 1 -2 3 -4 5 1 3 2 5
Output 1
1 2
Input 2
1 1 7 1 1
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.