karansrivastava's blog

By karansrivastava, history, 9 months ago, In English

I recently participated in Codeforces Round 895 (Div. 3) and encountered a Time Limit Exceeded (TLE) verdict for problem 1872F - Selling a Menagerie. Despite optimizing my code, I'm still puzzled by the TLE result.

I believe my code, with a time complexity of around O(10*n) which is near about o(n).

My code received a TLE verdict, which I find unexpected given its theoretical efficiency.

Could anyone please examine my code and share insights or optimizations.

Code Link: 222367949

Your assistance would be greatly appreciated.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

startpoints() is actually quadratic because curr is initialized up to n times. You can declare curr before the loop and make sure to undo the 1s each iteration