Interval Mex
题号:NC236456
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld

题目描述

For any multiset S (S may contain duplicated elements) of non-negative integers, define as the smallest non-negative integer that is not in S.

You are given a sequence of n non-negative integers and q queries.

For any interval (), let its weight be .

For each query, you are given an interval and a positive integer k. Find the k-th smallest weight among all subintervals of .

输入描述:

The first line contains two integers n,q (), denoting the length of the sequence and the number of queries.

The second line contains n non-negative integers () separated by spaces.

In the following q lines, each line contains three integers L,R,k (), denoting a query.

输出描述:

Output q lines. The i-th line should contain the answer of the i-th query.
示例1

输入

复制
5 5
1 0 3 0 2
1 5 3
3 4 2
1 3 4
1 3 3
2 2 1

输出

复制
0
1
1
1
1