Logo
(追記) (追記ここまで)

19497번 - Subtract if Greater! 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB86131117.460%

문제

Consider a multiset $A$ consisting of $n$ elements: $a_1, a_2, \ldots, a_n$.

Let us define two types of operations which can be performed on this multiset:

  1. Given $x_i,ドル you have to print the number which will be $x_i$-th element if we sort the multiset in non-decreasing order.
  2. Given $x_i,ドル you have to subtract $x_i$ from all the elements of $A$ which are strictly greater than $x_i$.

Your task is to perform $q$ given operations in the given order and output the results of all operations of the first type.

입력

The first line contains two integers $n$ and $q$: the size of the multiset $A$ and the number of queries (1ドル \le n \le 10^5,ドル 1ドル \le q \le 10^6$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ (1ドル \le a_i \le 10^9$): the elements of $A$.

Each of the next $q$ lines describes a single operation. An operation is given as two integers $t_i$ and $x_i$: the type and the parameter of the operation. It is guaranteed that $t_i \in \{1, 2\}$. If $t_i = 1,ドル then 1ドル \le x_i \le n$. If $t_i = 2,ドル then 1ドル \le x_i \le 10^9$.

It is guaranteed that there is at least one operation of type 1ドル$.

Please note that elements of $A$ are given in arbitrary order.

출력

For each operation of the first type, output the $x_i$-th element in non-decreasing order. Separate the answers with line breaks.

제한

예제 입력 1

4 5
1 5 6 12
2 5
1 1
1 2
1 3
1 4

예제 출력 1

1
1
5
7

예제 입력 2

5 4
1 10 5 4 2
2 1
1 5
2 3
1 2

예제 출력 2

9
1

예제 입력 3

3 2
3 2 1
2 10000
1 3

예제 출력 3

3

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 7: Ural FU Dandelion Contest C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /