I am a Java programmer. I find that many times even if my algorithm is correct, I get a Time Limit Exceeded on my submissions with codechef. Are there some techniques that one should employ while submitting solutions in Java in programming contests?
Share
On CodeChef, all submissions in Java have 2x of the time limit than their native language (eg, c/c++/pascal) counterpart. However, one thing that goes unmentioned is that the Judge starts behaving very slowly when the memory consumption goes high which happens quite often with Java solutions. The CodeChef judge runs with a memory setting of 64 MB for all Java programs. You should try and use as less memory as possible and try and run the same solution locally with -Xms = 64 MB.
The increased time limit can also be caused by the fact that when program’s memory usage draws near to allowed maximum (which is 64 MB in this case), then the JVM invokes the garbage collector which uses CPU very intensively and hence delays the program execution.