Please consider the following 3 submissions:
- http://codeforces.net/contest/417/submission/6396718
- http://codeforces.net/contest/417/submission/6396720
- http://codeforces.net/contest/417/submission/6396723
The same code has been executed with Java 6->7->8 compilers. Outcome is:
- 702 ms (Java 6);
- 1000 ms TLE (Java 7);
- 998 ms (Java 8).
I assume that the issue is in 32-bit and 64-bit based compilers. I guess that CodeForces uses 32-bit one for the Java 6 only.
So I've been more than surprised (it's not like 850ms vs 900ms — it's 30% faster!). I'd like to get some explanations from the community on this matter. I can also see that many people here use Java 7 or higher. So what's the reason behind this (having the problem from above?)
Maybe this solution was just specific (e.g. memory usage and stuff) or kinda buggy? Or we can see such performance degradation on every submission?
Anyway, let it be at least a friendly reminder for all Java-users to think twice, before pressing the "Sumbit" button.
I submitted the same code twice (Java 6/8) just now, and got a kind of different result from yours.
http://codeforces.net/contest/408/submission/6397501 http://codeforces.net/contest/408/submission/6397506
Java 6 : 109 ms Java 8 : 217 ms
It's interesting to know though.
I'll consider using different version of Java when I got TLE for the solution I'm really sure about.