Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

dp_hunter's blog

By dp_hunter, history, 8 years ago, In English

Hi codeforces.

I tried to solve this problem and for my interest I wrote the same problem in Java and after this in C++.

And this are the results :

Java = 1092ms;

C++ = 421ms;

So C++ is ~ 2,5 faster than Java, so this difference can make you win or lose a problem during the contest.

Maybe I make something wrong in Java and Java is faster than I think? So I have few day since I start to solve in Java ,hope to receive from you good hints for making my Java program run faster.

I didn't make any changes in C++ program, just rewrite the same program from Java to C++

  • Vote: I like it
  • -17
  • Vote: I do not like it

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

so this difference can make you win or lose a problem during the contest.

I've heard that usually the author's Java solution is used as the criteria when determining the time limit. As a result, a proper Java solution should not fail without using some unfamiliar tricks.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

So C++ is ~ 2,5 faster than Java,

I'm afraid this is well known fact :) Java is compiled to byte-code, not to machine-code, so even with JIT-compiler it is expected to be somewhat slower on average.

However people behind CodeForces are smart enough so usually it could be trusted that correct solution will not get TLE even in java — and usually (not always) time inefficient solution will not get AC in C++.

By the way, you can browse the people in Top-10 and find out that some of them do code mainly in Java.

»
8 years ago, # |
Rev. 6   Vote: I like it +1 Vote: I do not like it

I don't wanted to offend someone by writing this blog. Java became in this few weeks one of my favorite programming languages.I just wanted to know some hints or ideas to make Java faster and to use 100% of its power.Thank you for reading this blog.Wish you all the best ;)