问题 1114. -- Array of Orz Pandas## 1114: Array of Orz Pandas

时间限制: 3 Sec 内存限制: 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. Let *f(l,r)* = ∑[A[i]≥K1 and A[i]≤K2] .i is from l to r inclusive. [*Expression*] means that* Expression* is a logical expression, if the expression is true, then [*Expression*] is 1, else 0. Calculate the result of *f(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 integers* ***l ,r** K1, K2.

There are several test cases, please process to end of file.

1 ≤ N ≤ 100000, 1 ≤ M ≤ 100000.

0 ≤ A[i] ≤ 10^9, 1 ≤** ***l *≤* r* ≤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

## 提示

## 来源

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