I am trying to solve this problem : http://www.codechef.com/problems/MSTICK/
I already posted on the Editorial thread relative to the MSTICK problem but no one answered.
Here is my solution to this problem : http://www.codechef.com/viewsolution/4172545
I don’t know what’s wrong with it, it gets TLE.
I implemented the segment tree data structure and I “think” the complexity of my algorithm is O(2N + 4Q*log(N)) which comes as follow :
O(2N) for building 2 segment trees, one to find the minimum and another to find the maximum.
O(4Qlog(N)) since I run 4 Range_Min(Max)_querys for each query Q.
Everything seems to be working but I still don"t understand why I am getting TLE.
If anyone can help me please?