Why time increases?

I am new to Codechef,recently I solved the DOUBLE problem.It is the simplest problem I ever got on
But I have one doubt, I gave two solutions(5668465,5668449).
5668449 solution taken 0.10 sec while 5668465 taken 0.12 sec. Second solution has more
generalized solution, as I merge one condition. So it should take less than 0.10 sec but to contradict
it is taking .02 sec more.
Can anybody explain that.
Thanks in advacne.

Time measurement is not absolutely precise. Such a small difference like 0.02 seconds can be due to a compiler optimization done in one case and not the other or even server load.

Don’t sweat over such small time differences. Time limits are usually large enough that proper algorithms pass comfortably.


Please post links to your solutions

Correct, it is possible that same solution gives different results (time wise).

1 Like

what if the time limit is 1 sec & problem takes 1.02 sec, will it be accepted as correct ans???


It will get time limit exceeded in that case. The important thing to note is that the intended solution in most contests usually uses at most 1/3 of the time limit. So, if your code is using 1.02 secs, you’re probably using a bad algorithm.

1 Like