#P64. [KBC005Ex] Standings
[KBC005Ex] Standings
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Background
The spherical elf pl launched Slay before taking the ABC contest. At this moment, the coach came in, so he had to pretend to be working on data structures.
Problem Description
Given a sequence of length , you need to support operations of the following type: let be the -th smallest value in , afind the number of elements equal to in .
Input Format
The first line contains two positive integers , representing the length of the sequence and the number of subsequent operations respectively.
The second line contains positive integers , describing the sequence.
Each of the next lines contains three positive integers $l, r, k\ (1 \le l \le r \le n, 1 \le k \le r - l + 1)$.
Output Format
For each query, output a single line with a positive integer representing the answer to that query.
Samples
5 3
3 1 4 1 5
1 3 2
2 5 3
1 5 1
1
1
2