主页 讨论版 问题 名次 状态 统计

请自觉遵守比赛规则,违者严惩,不接受求情!

问题 A: Array of Orz Pandas

问题 A: Array of Orz Pandas

时间限制:3000 ms 内存限制:128 MB
提交:100 解决:30
[ 提交][ 状态][ 讨论版]

题目描述

There are several small pandas in Panda emoticon. There are N Panda emoticons in row. The numbers of small pandas in i-th Panda emoticon is A[i], i is from 1 to N. Letf(l,r)= ∑[A[i]≥K1 and A[i]≤K2] .i is from l to r inclusive. [Expression] means thatExpressionis a logical expression, if the expression is true, then [Expression] is 1, else 0. Calculate the result off(l,r).

输入

The first line of the input contains two integers N and M denoting the number of Panda emoticons and the number of queries. Next line contains N integers denoting A[i].
Next M lines, each line contains four integersl ,rK1, K2.
There are several test cases, please process to end of file.

1 ≤ N ≤ 100000, 1 ≤ M ≤ 100000.
0 ≤ A[i] ≤ 10^9, 1 ≤lr≤N.
0 ≤ K1 ≤ K2 ≤ 10^9.

输出

For each test case, output M lines, i-th of them is the result of the i-th query.

样例输入

4 2 1 2 3 4 1 3 2 3 1 1 1 1

样例输出

2 1

提示

[ 提交][ 状态][ 讨论版]
Baidu
map