I'm trying to solve a RMQ problem at lightoj using Segment Tree , but it always gives me TLE. Can anybody help in pointing out my mistake ?
Problem link : http://www.lightoj.com/volume_showproblem.php?problem=1082
Code link : http://pastebin.com/UqaumDKG
I had the same problem many times in SPOJ. First, try replacing 'endl' by '\n'. If still TLE, try using stdio.h instead of iostream.
Thanks ,replacing it with stdio.h get me accepted.
Did you notice the following:
In such cases, for
C++
,<cstdio>
is required instead of<iostream>
.