Getting TLE in my java solution using similar solution to others Accepted soulution.. plz Help

problem link

editorial link

my all submissions

all other users AC submission in java

plz someONe Help getting TLE exceed
i used same approach(algo) “sieve” as given above but geting TLE
I TRIED MY BEST TO OPTIMISE MYCODE TO GIVE AC BUT failed

1 Like

Time limit is too tight for this question (2*0.127796 ~ 0.25 seconds for java).
You can see my submissions–

I took same approach as you and got TLE. Even BufferedReader couldn’t avoid TLE.
Then i saw one submission of 0.14 seconds which used fastest method for reading input in java( refer https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/ )
Got accepted by using same method for fast input with 0.13 seconds execution time.

1 Like

Thanks Bro, i did it using that 4th approach to take input… myTest Case passed in .09 seconds…(i guess fastest among all submited solution of java )…
thank YOu Very Much :slight_smile:

1 Like