Akhmadzhanov's blog

By Akhmadzhanov, history, 23 months ago, In English

Today I wanted to solve this problem: Heavy Intervals But I got TLE3 code: 260013398. that's why I changed the code a little bit and my code(260014069) was correct. But I don't understand how? Can you explain?

Here are the differences between my first and second codes

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

| Write comment?
»
23 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

for sets , b.upper_bound is O(log(n)) but upper_bound(all(b)) is O(n)

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

Using set.upper_bound() is O(log n), while std::upper_bound(set.begin(), set.end(), value) adds O(n) complexity due to linear search, potentially causing time limit.