My submissions are running too slow.

What computers do you use for testing the solutions?

My solution for problem runs locally in 0.150 seconds, but I got TLE on the server with time limit = 1 sec.

Is there any way to run solution on the server, to learn, how much time does it work?

I can’t be confident if my solution works in time and I can’t know should I optimize it or it already passes the systests.

Update: I learnt that Java gets twice time limit time, am I wrong? If so, then my solution didn’t pass in 2 sec time limit. Then I optimized my solution, it worked in 0.1 sec on my computer, server gives 1.56 sec run time.

Yes, Java submissions take 2x the time limits specified.

The judge system on CodeChef receives numerous submissions per minute. The time limits are set considering this factor. Your local computer takes minimal time because of the resources at its disposal which may not be the same for a server which processes numerous submissions in a minute.

Also the time limits for the problems are set by our experienced panel of problem setters after extensive testing. I am sure if you’ll optimise your submission you would be able to get it running within the time limits on CodeChef judge. You can read more about optimising your problem for TLE here

1 Like

Well the time limits on codechef are drastically different from our local machines. One thing I normally do is check frequently by putting breaks on heavy pre-computation which should be the same irrespective of the test case and compare the time taken on server and the local machines ans see what times on local machine might be sufficient to get it accepted on server (This works well with long contest and not in shorter format due to penalties). After doing this in few problems I came to the conclusion that for my laptop the code needs to run on a worst case input in 0.35s if the TL on codechef server is 2s (Will not be same for your machine though). You can try this experiment for your machine in the practice area or while doing a long contest the next time.

3 Likes

Actually, you didn’t answer my important questions. How to get rid of TLE is not so important, because it’s obvious how to do.

More important is: “Is there any way to run solution on the server, to learn, how much time does it work?” and “What computers do you use for testing the solutions?”

And I have another question about Java. Is it 32 bit or 64?

Do you count CPU time or real time?

Why on other sites, such as CodeForces, TopCoder, acm.timus.ru, our solutions run almost in the same time as on local computers.

You say that the reason for it is that your server processes many solutions at the same time. Is it fair that running the participants’ solutions depend on what time did he submit it at.

Codechef use SPOJ judge for running your code. and that system is kinda old … as their system’s RAM is definitely less as compared to other judges… :slight_smile:

1 Like