I have submitted so many solutions for SDSQUARE when i submitted two wrong answered solution both take 1.34s THIS and 1.35s THIS even though both are same and my right solution THIS takes 2.01s in every submission. Why ?
The time required by a solution might change by a small value(0.01 - 0.02) depending on the load on the server.
The solution you showed that took 2.01 secs was giving TLE. The judge runs your code and the moment it exceeds the time limit it is stopped and you are given TLE as verdit.The time limit for this problem was 2 seconds so the moment your code exceeded that i.e. at 2.01, its execution was stopped. hence you always get 2.01 as time for tle case
The time 2.01 does not mean that the execution did finish at 2.01.As my dear friend @kcahdog said the server stops the process of execution at the time just after the total time limit.
This is a major misconception among the people here.It has been well explained by @kcahdog
but i tried so many times even i removed one whole loop to reduce its complexity but it shows me TLE every time.
@smitdhilu:http://www.codechef.com/viewsolution/2925671
Check my code if you meant to have reference…
What i have done is using the method of sqrt of n i have pre calculated the result and stored the entire set of answers in an array…
Then i made a search…
Hope this will help you…
My code may not be the right procedure.But i found that as the easiest way…
here is the tutorial for the above mentioned problem:http://discuss.codechef.com/questions/28740/sdsquare-editorial
Hope this can help you.
All the best
This all depends on the load of server and the time changes 0.01 - 0.02s as per the load only and your program completes its execution in 2.01s so it shows you TLE.
hope you got my answer.