TLE matchstick

Was trying to solve http://www.codechef.com/problems/MSTICK by Segment tree but still TLE pops up…:(.
Heres my code .plz help me out…:frowning:
http://www.codechef.com/viewsolution/3448843

1 Like

One suggestion to the solution is do integer operation at each node of the segment tree. Floating point operations are more complex and takes more time to operate. Just store the maximum and the minimum values of the ranges which are integer values. That would work fine.

1 Like
//