help required in spoj problem KGSS

segment-tree
spoj

#1

Can someone please help me with this [problem][1] from spoj on segment trees. I am storing maximum and second maximum element at each node of tree but getting wrong answer.
Here is my


[2].
Any help is appreciated.:)


  [1]: http://www.spoj.com/problems/KGSS/
  [2]: https://ideone.com/mOvfZ5

#2

There is a small mistake. The update operation “sets the value of A to x*”, not to max(A*, x).


#3

Thanks man! Helped a lot :slight_smile: