Need Help in Problem (Cosmic Table)

So i was solving a problem named Cosmic Table and i’m getting a stubborn TLE on test 12 while submitting. My code is correct and is also correct in terms of time complexity. It should have passed but it does not.

Can someone please help me find out why is my code getting TLE, even after its Time Complexity is correct.

My Submission (TLE)

Could just be the time taken to read in all the input, since you’re using unbuffered iostreams.

Maybe try adding the line:

    ios::sync_with_stdio(false);

before you read start reading the input; remove the call to scanf (since we’re now using buffered input for iostreams, which will conflict with all the C-style input function’s buffers) and try submitting again.

2 Likes

Thanks that was it :slightly_smiling_face: Got AC

1 Like