I need to devise a data structure $S$ with the following functions:
- BUILD($S$) - build the data structure from a series of $n$ elements in time $O(n \lg{n})$
- INSERT($S$, $k$) - insert a new element with the key $k$ to $S$ in time $O(\lg{n})$
- DELETE($S$, $p$) - delete the element $p$ from $S$ in time $O(\lg{n})$
- D-SUCCESSOR($S$, $p$, $d$) - return the $d$-successor of $p$ in time $O(\lg{n})$ where $d$-successor of $p$ is the $d$-th element after $p$ if the elements where ordered by their key
- DECREASE-UPTO($S$, $k$, $val$) - decrease by $val$ all keys in $S$ where the key is not larger than $k$, in $O(\lg{n})$ time
I've managed to do the first 4 points using order static tree, as an extension of red black tree, but I'm having trouble with the last one, assuming $k$ is bigger than all elements in $S$ the function will need to update the values of all $n$ elements in $S$ how can this be done in $O(\lg{n})$ time?