Check my soln https://www.codechef.com/viewsolution/19410708
Please answer clearly.
The link U are providing does not provide ur solution.Can u give another link
U can see the editorial of the problem “https://discuss.codechef.com/questions/132596/splst-editorial”
I guess u are going wrong with the condition part.