Блог пользователя dp_hunter

Автор dp_hunter, история, 8 лет назад, По-английски

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++

  • Проголосовать: нравится
  • -17
  • Проголосовать: не нравится

»
8 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, # |
Rev. 6   Проголосовать: нравится +1 Проголосовать: не нравится

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 ;)