Micro and Shopping
Practice
3.7 (525 votes)
Ready
Hiring
Bit
Approved
Easy Medium
Problem
59% Success 5908 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Micro's girlfriend Mini wants to go to shopping with Micro. Of course, Micro will be taking care of all her expenses. She wants to go to Code Mall for shopping. There are N shops in the mall, numbered 1 to N. Each shop is having a standard S ,represented by an integer value. Since she understands that Micro is undergoing a financial crisis, she will only go to those shops with standard less than or equal to c, but she wants to go to shops whose number lie between a and b. Now Micro wonders for different given values of a, b and c, how many shops he will have to visit.

Input:
First line consists of two space separated integers N and Q denoting the number of shops and number of queries respectively.
Second line consists of N space separated integers. ith integer denotes the standard of ith shop.
Q lines follow each containing three space separated integers a, b and c.

Output:
For each value of a, b and c print the answer in a new line.

Constraints:
1 ≤ N ≤ 100000
1 ≤ Q ≤ 100000
1 ≤ S , c ≤ 1000000000
1 ≤ abN

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
290 votes
Tags:
ReadyBit manipulationApprovedEasy-Medium
Points:30
103 votes
Tags:
Easy-Medium
Points:20
95 votes
Tags:
EasyImplementation