Question about time complexity of two problems from today's contest

Правка en1, от mihajlovskijr, 2024-04-08 21:38:41

I spent really a lot of time during the today's contest trying to make my E solution faster, even though it should have O($$${n^2}logn$$$) complexity, which is with n <= 5000 should pass the 3 second limit. The only thing that helped me was changing long long to int, but even so, it's still very slow. Does anyone have any idea why my E solution is so slow (below is the final one)? And a similar question is about D as well, because I can't see any clear reasons why it is so slow:

E: 255741981
D: 255675779

Sorry about how code in E looks like, I don't know why it shifted, because for me it was totally normal when I was sending it.

Теги contest, time limit, time complexity

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
ru1 Русский mihajlovskijr 2024-04-08 21:43:32 934 Первая редакция перевода на Русский
en1 Английский mihajlovskijr 2024-04-08 21:38:41 888 Initial revision (published)