I think you can apply a Merge Sort Tree.

I solved a similar problem a few days ago where I had to find the value closest to `k`

in a given range [L, R]. The problem was LRQUER.

In your case you can do the following:

Instead of storing a single value in any node, you can store a range. This range will be the sorted list of the values stored in its children. Then, while querying, you will query in this range. For a single query `[L, R]`

, you can find the `upper_bound()`

and then return the minimum of all the values found like this.

Edit: To handle point updates, we’ll have to update the corresponding parent nodes too. We can update a node in O(log(n)) time by searching for the previous element and then inserting a new element, using something like `std::set`

(because we have to store the elements in sorted order) in C++. If duplicate elements are allowed, then we can use `std::multiset`

in C++.

Now, there can be at most O(log(n)) updates in a **single update operation** because the depth of the tree will be of the order of log(n), making the complexity O(log^2(n)).