Help with TLEs

Revision en2, by yesbutno1685, 2020-09-17 07:36:41

I have a question on this question: https://codeforces.net/problemset/problem/1409/E

I am getting a TLE on test five (or when n hits its maximum value). My code gives the correct answer, given infinite amount of time, I just need help on figuring out why it TLEs.

From my knowledge, all I do is binary search and do a linear scan, so that's about nlgn time. However, when I submit it, it does not run in time, so I suspect that there is something that I am not catching. I've tried for a long time and still could not figure out why my code is TLE-ing.

I hope you guys can help me out

Thanks in advance!

code (in java): https://codeforces.net/contest/1409/submission/93014244 [](https://codeforces.net/contest/1409/submission/93014244)

Code

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English yesbutno1685 2020-09-17 07:37:07 62
en2 English yesbutno1685 2020-09-17 07:36:41 8
en1 English yesbutno1685 2020-09-17 07:36:19 3920 Initial revision (published)