given a cluster a comprising of n integers. At first all components of an are either 0 or 1. You wanted to deal with q inquiries of two sorts: 1 x : Assign to cut out the worth 1−ax. 2 k : Print the k-th biggest worth of the cluster.
Correct answer will be upvoted else downvoted. Computer science.
You are given a cluster a comprising of n integers. At first all components of an are either 0 or 1. You wanted to deal with q inquiries of two sorts:
1 x : Assign to cut out the worth 1−ax.
2 k : Print the k-th biggest worth of the cluster.
As an update, k-th biggest worth of the cluster b is characterized as following:
Sort the cluster in the non-expanding request, return k-th component from it.
For instance, the second biggest component in exhibit [0,1,0,1] is 1, as in the wake of arranging in non-expanding request it becomes [1,1,0,0], and the second component in this cluster is equivalent to 1.
Input
The principal line contains two integers n and q (1≤n,q≤105) — the length of the given cluster and the number of questions.
The subsequent line contains n integers a1,a2,a3,… ,an (0≤
Every one of the accompanying q lines contains two integers. The main integer is t (1≤t≤2) — the sort of question.
In the event that t=1 the subsequent integer is x (1≤x≤n) — the situation of the altered number. You need to appoint to hack out the worth 1−ax.
In the event that t=2 the subsequent integer is k (1≤k≤n) — you wanted to print the k-th biggest worth of the exhibit.
It's surefire that there will be something like one inquiry of the subsequent kind (fulfilling t=2).
Output
For each inquiry of the subsequent sort, print a solitary integer — the response to the question
Step by step
Solved in 4 steps with 1 images