21August's blog

By 21August, history, 5 years ago, In English

Hi everyone. Can somebody provide an working code of a segment tree that supports following operations:

  1. Subtract value on suffix of array.
  2. Assign a range with the smallest element in that range.

It is guaranteed that the array is always sorted in ascending order after each operation. I would like a code that implements this using lazy propagation. I tried to write such a code for the problem Jousting tournament . Here is a code of the segment tree. Also i have a function "kth" that find the last occurrence of a value in the array. The functions "up" , "push", "build" are used for this part of the problem. Please help to debug or give me another code.

  • Vote: I like it
  • -4
  • Vote: I do not like it