AlgoUniversity
  • Go Back
Discussion
Tax Payment :

Author

Ayush Gangwani

Difficulty Level : Hard

Submissions : 167

Asked In : Sprinklr

Marks :20

: 3 | : 0

You are given an integer array $$$A$$$ containing $$$n$$$ integers. You need to answer $$$q$$$ queries of the following form:

  • $$$l$$$ $$$r$$$ $$$x$$$ — Find the number of integers greater than $$$x$$$ in the subarray $$$A[l:r]$$$

Input

The first line of input contains two space separated integers $$$n$$$ and $$$q$$$ $$$(1 \le n,q \le 10^5)$$$ — the number of elements in the array $$$A$$$ and the number of queries respectively.

The second line contains $$$n$$$ space separated integers $$$a_0, a_1, ... a_n$$$ $$$(1 \le a_i \le 10^9)$$$ — denoting the elements of the array $$$A$$$.

The next $$$q$$$ lines each contain three space separated integers $$$l$$$ $$$r$$$ $$$(1 \le l \le r \le n)$$$ and $$$x$$$ $$$(1 \le x \le 10^9)$$$ — denoting the queries.

Output

Print the answer to each query in a single line.

Example

Input
5 2
1 2 2 3 5
1 5 2
2 4 1
Output
2
3

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.