+ 3
Why my code throws time limit exceeded warning?
I am currently solving a problem on codechef, now i have written a code that outputs the correct answer for subtask2, as i was confused about how to implement logic for subtask 1. but my code submission throws TLE, what could be the better and cleanest way to ensure the time complexity. Also if someone can guide me through the subtask 1 logic, as i cannot determine how to check whether there is draw in the match(as per the problem). Any help is highly appreciated! Thanks here is the problem link on codechef: https://www.codechef.com/ICO20MCK/problems/SINGTOUR here is the code link: https://code.sololearn.com/cINy84162eiv
7 Antworten
+ 3
Gaurav Agrawal
Got it , but how can I test for a draw match ?
What logic should I implement ?
BTW thanks for your valuable reply
+ 3
pitch values for a singer:
{$L, L+1, L+2, ..., U-1, $U}
1)equal range will be draw:
●------------------------------------●
2)lower limit <$L and upper limit <$U will lead to draw:
<------------------------------------<
3)lower limit >$L and upper limit >$U will lead to draw:
>------------------------------------>
//to improve time complexity more, you can use nC2 comparisions instead of (n-1)*n comparisions.
+ 2
hey, Gaurav Agrawal I have updated my question details and added the links of the problem and the code along, please review it and guide me.
+ 2
Hey Gaurav Bhaiya thanks for your answer I will try it for sure and will update here .
Thanks for your valuable time !
+ 1
I believe you are using BufferReader instead of Scanner as it is more efficient. If you are facing TLE then its the problem in your logic.
Please post exact problem and the code which you have written(unable to view on reddit), me or some community member can try.
+ 1
Pranshu Ranjan
-use BufferReader instead of Scanner
-you don't need to look for every pitch in range to compare two singers, looking boundary pitches(lowest and highest) are enough to compare two singers.
+ 1
Hey Gaurav Bhaiya , ahh! I forgot to update you , thanks for your answer now it's works .
Thank you very much for your valuable time .