alyosha's blog

By alyosha, history, 13 months ago, In English

https://codeforces.me/contest/2149/submission/340722817 this is my submission it is failing by TLE on testcase 15. I don't understand why. I have implemented the same approach as given in the editorial. I compress the values of array A and the do 50 tries of randomly checking if count of some value in [L, R] > (r — l + 1)/3.

Any help will be appreciated. Thanks

  • Vote: I like it
  • -2
  • Vote: I do not like it

»
13 months ago, hide # |
← Rev. 2  
Vote: I like it +11 Vote: I do not like it

The reason of TLE is big constant behind your solution.

If you improve line 54 of your solution from $$$O(\log(n))$$$ to $$$O(1)$$$, you will get AC: 340741082

From 4.5s+ to 1.9s.