For a few of the CSES Sorting and Searching problems, such as Apartments, Concert Tickets, and Traffic Lights, and Movie Festival 2, I can't avoid TLE on the largest testcases in java.
Here is code for Movie Festival 2, https://ideone.com/AKdglG
I am using bufferedreader already, but CSES time limit seems to strict. Any tips? Or should I accept my fate as a java user and not care since CF and other platforms don't have 1sec limits?
I have had the same fate as you. In many of the CSES problems the simple streamReader IO is not enough, you will need to implement buffered reading yourself, I used the 4th code from here https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/ , that has so far gotten most codes ac'ed in CSES for me.
Also to people downvoting, I don't see any reason this question should be downvoted. If you think it's a copy of an old question, the minimum you could do before downvoting is post a link to an old question, no?
I used PriorityQueue for 'Apartments' problem. It worked
Hey could you send the link to your code? It would be of GREAT HELP!
Apartments soln (Java) — https://cses.fi/paste/83798472eadfac51d2a9d/
Thank you so much bro!
Using Collections.sort insetad Arrays.sort may work... it worked for me
Having the same issue here, hopefully pllk can make a change for this.
I've avoided some TLEs by taking out the multiple print statementsand appending to a StringBuilder instead. Then I print just once at the very end.
https://codeforces.com/blog/entry/67743?#comment-694976 pllk?
For simple problem like coin combinations 2 even if we use bufferedreader. its showing tle please help if u can . and with same complexity its running in cpp... what to do?? https://cses.fi/problemset/result/1979284/
Same problem bro!! Have you found any solution or still relying on the fate????????
I was able to solve this for "Apartments" by shuffling the array before sorting. The reason being the input is triggering the worst case time complexity of O(n^2) of quick sort used in JDK8.
same code works in c++ not in java. Same complexity. Talking about Coin Combination 1 & 2 on CSES. Despite of using FastReader given on GFG
https://cses.fi/problemset/task/1130/ i dont know how to resolvet tle, does anybody know how to avoid tle in this problem? here is my code https://cses.fi/paste/834ba3770f78bf8923b704/
I have used ArrayList instead of Array and it worked. here is my code Link