Solution should be faster due to lesser amount of operations but gives TLE?

Правка en1, от wck_iipi, 2025-02-02 23:32:36

I was doing the following question: https://codeforces.me/contest/2044/problem/F

Upon doing this question, I used a method that gives the solution in O(nq) time (about 2 * 10^5 * 5 * 10^4 = 10^10 operations). Code is as follows:

https://codeforces.me/contest/2044/submission/304178376

Spoiler

However, the official solution is in O(n^2) time, which is about (4 * 10^10 operations). https://codeforces.me/blog/entry/137306

Spoiler

My solution, however gives TLE. Why is my solution giving TLE but official is not even though operations are lower?

Теги online judge, time limit exceeded, speed, array

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский wck_iipi 2025-02-02 23:32:36 8411 Initial revision (published)