Блог пользователя ravi_sumit33

Автор ravi_sumit33, история, 6 лет назад, По-английски

Hello Codeforces!

I was solving this problem and came up with an approach using set. I made submission but got TLE. If I am correct, time complexity of this submission is nlogn as total number of insert/erase operations in set is O(n) and logn for each upper_bound.

I know this approach is not the best one but considering constraints given in the problem, this should get an AC.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Try replacing upper_bound(all(st0), p) with st0.upper_bound(p).