#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 the interval , and find the number of elements equal to in the interval.
Input Format
The first line contains two integers , representing the length of the sequence and the number of subsequent operations respectively.
The second line contains integers , describing the sequence.
The next lines each contain three integers in the format l r k.
Output Format
For each query, output a single line with an 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
Data Range
,,,.