Apple trees 4 - MarisaOJ: Marisa Online Judge

Apple trees 4

Time limit: 1000 ms
Memory limit: 256 MB
Marisa planted n apple trees in a row. Each tree, denoted as the ith tree, can initially grow apples of size Ai. However, due to the rain, some trees mutate, resulting in changes to the sizes of their apples. There are q event that happen chronological order: - 1ix: apples on tree i change their size to x. - 2lrk: For her research purposes, Marisa conducts a query in the form of (l,r,k).She needs to find the kth smallest apple size among the trees in the range [l,r]. Please help her answering these queries. ### Input - The first line contains two integers n,q. - The second line contains n integer Ai. - The next q lines, each line contains a query in the aforementioned format. ### Output - Print an integer, which represents the answer for each query of type 2. ### Constraints - 1≤n,q≤105 - 1≤Ai≤109. - 1≤l≤r≤n. - 1≤k≤r−l+1. - 1≤i≤n. - 1≤x≤109. ### Example Input: 533721821311222243 Output: 22
Topic
Binary search
Data structure
Rating 2200
Solution (0) Solution