help required in spoj problem KGSS

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

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

1 Like

Thanks man! Helped a lot :slight_smile: