DMOPC '19 Contest 2 P3 - Selection

View as PDF

Submit solution


Points: 12
Time limit: 1.4s
Python 4.5s
Memory limit: 256M

Author:
Problem type

Veshy has a box with N items, the ith of which has a "goodness" of gi on Veshy's standards. Over a period of M minutes, one of two events may occur. On the ith minute, either Veshy's standards have changed and the aith item's "goodness" has changed to bi, or he wants to know the goodness of the cith best item in the subarray of items, gli,gli+1,,gri.

It is recommended that Python users use PyPy instead.

Constraints

In all subtasks,
1N300000
1M100000
0gi,bi20
1ai,li,ri,ciN

Subtask 1 [10%]

N100

Subtask 2 [30%]

0gi,bi1

Subtask 3 [60%]

No additional constraints.

Input Specification

The first line contains two space-separated integers, N and M.
The next line contains N integers, the ith of which being gi.
M lines follow, each of which are either in the form:
1 a b - the aith item now has goodness bi
2 l r c - Veshy wants to know the goodness cith best item in the subarray of items: l,l+1,,r

Output Specification

For each query, output the goodness of the cith best item in the subarray of items. It is guaranteed that there are at least ci items in the subarray.

Sample Input

Copy
5 5
3 15 19 7 14
2 2 4 2
1 2 9
2 1 2 2
1 5 17
2 1 5 3

Sample Output

Copy
15
3
9

Comments

There are no comments at the moment.