Need help with TLE

Правка en1, от yodacodes, 2025-02-13 16:20:38

Problem link: https://codeforces.net/problemset/problem/2060/C 1st Submission: https://codeforces.net/problemset/submission/2060/305937191 2nd Submission: https://codeforces.net/problemset/submission/2060/305932678 Language used: Python

Not an input/output related issue.

After my submission, I checked some accepted solutions. Some of them even sort the numbers before solving. It is supposed to take nlog(n).

In any case I tried to sort the map keys, so that I don't have to iterate through all map/dictionary items. But even then I'm getting TLE. Is it the choice of data structure?

Can someone help me understand what is going wrong. I am trying to learn for future problems.

Also, would be great if someone can share any resource for python optimizations to avoid TLE

New user posting for the 1st time. Please let me know if I missed any information.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский yodacodes 2025-02-13 16:23:36 5
en1 Английский yodacodes 2025-02-13 16:20:38 903 Initial revision (published)