Unnecessary TLE in JAVA in LTime75A

In the the contest i had submitted my code in JAVA for Chef Drinks Coke Yet Again (COKE2)

I got a TLE in one of the subtask 2 cases in JAVA.
I copied my code in cpp, made the necessary changes, and voila!! My code gets accepted!!
I wasted about 15-20 mins converting my code to cpp, which affected my rank.
Can you please do better testing so such cases don’t happen @admin ?

Here are links to my solutions, you will find that both are DITTO same:
JAVA : https://www.codechef.com/viewsolution/26181207
CPP: https://www.codechef.com/viewsolution/26185132

2 Likes

maybe bcz u used fastIO in cpp and btw cpp is always faster than Java … google it why u will get whole detail

1 Like

CodeChef doesn’t like Java :slight_smile:

Seriously, tuning the time limits for various languages is quite a difficult task, I don’t think there is a good solution to that.

In general, I have a feeling that switching to C++ will increase one’s productivity by roughly 20%, just because of the language change.

well everyone knows cpp is faster than java but there is a thing called time multiplier different for each language. so that algorithm which runs in cpp in unit sec can run in others languages accordingly.
PS: it might happen that time multiplier isn’t same for each problem.

Java is a favorite among developers, but because the code must first be interpreted during run-time, it’s also slower. C++ is compiled to binaries, so it runs immediately and therefore faster than Java programs. … Java does not support pointers, so you are only able to pass values using value references.

Well i used Fast IO in JAVA too. And yes, i am aware Cpp is faster, but it is the responsibility of testers that JAVA and other programmers coding in other languages don’t get unfair disadvantage due to this.

2 Likes

It is a very naive approximation and simplification to believe that execution time in Java can be expressed as a simple function compared to the one in C++. Whoever thinks that Time(Java) = Multiplier*Time(C++) … should basically forget about Computer Science and change their field

[quote=“fuckingcoding, post:5, topic:36506”]
ecause the code must first be interpreted during run-time, it’s also slower. C++ is compiled to binaries, so it runs immediately and therefore faster than Java programs. … Java does not support pointers, so you are only able to pass values using value references.

Yeah man…i have faced this issue on codechef many times

read my above comments again…
. for even better performance you may use brainfuck… but u know what will happen next LOL :smile:

1 Like

Many people got 100 in Coke2 using java. so i think there is no Java issue…similar thing happened with me in Destroy Cells problem using java…

1 Like

@taran_1407 is almost 7* on codechef using java .

1 Like

they want java users to optimize their code and learn new methods… so make u learn new methods… for which u shouldnt be complaining instead say thanks XD

Many people getting AC doesn’t mean the issue i faced is isn’t valid.
If the same solution in cpp gets AC then don’t you think there was an unfair disadvantage to me?

no … @vijju123 will clarify more

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

ur code seems optimal afik but obj creation is costly op. Hence the ‘pair’ might be the reason
also I am not sure if generics affects execution time as they are resolved in compile time

I am telling in this respect this is totally crap statement

it happens
the tester is not responsible for writing the code in every lang
do u know every lang ?
sad truth man but java is not for CP
I too use java and face this issue in CP

It depends on you/me how you code and how much knowledge you/me have about the language.
eg: better example Arrays.sort() in java…