You are given an array $$A$$ of $$N$$ numbers and you need to answer $$Q$$ queries of $$2$$ types on it. In the first type query, you are given an integer $$X$$ and you need to subtract $$X$$ from all numbers with value greater than or equal to $$X$$. In the second type query, you are given $$3$$ integers $$L$$, $$R$$ and $$X$$, and you need to print the $$X^{th}$$ smallest number with value between $$L$$ and $$R$$ (both inclusive). If there are less than $$X$$ numbers with value between $$L$$ and $$R$$, then print $$L$$.
Input:
The first line contains $$2$$ space separated integers $$N$$ and $$Q$$, denoting the number of elements in the array $$A$$ and the number of queries. Second line contains $$N$$ space separated integers, denoting the elements of the array $$A$$. Each of the next $$Q$$ lines describe a query. If it is a first type query, you will be given $$2$$ space separated integers where the first integer would be $$1$$, denoting that it is a first type query and second integer would be $$X$$, as defined in the problem statement. If it is a second type query, you will be given $$4$$ space separated integers where the first integer would be $$2$$, denoting that it is a second type query and next $$3$$ integers would be $$L$$, $$R$$ and $$X$$, as defined in the problem statement.
Output:
For each query of the second type, print the $$X^{th}$$ smallest number with value between $$L$$ and $$R$$. If there are less than $$X$$ numbers with value between $$L$$ and $$R$$, then print $$L$$.
Constraints:
$$1 \le N, Q \le 2 \times 10^5$$
$$1 \le A_i \le 10^{18}$$
$$1 \le L \le R \le 10^{18}$$
$$1 \le X \le N$$
5 2 3 8 1 4 5 1 2 2 2 20 2
3
The $$3$$ numbers between $$2$$ and $$20$$ are $$2$$, $$3$$ and $$6$$.
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
Login to unlock the editorial
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