Taan's blog

By Taan, history, 7 years ago, In English

If I have a set( priority queue) <C++ stl> can I know the middle element of that set (priority queue) in O(log) ?

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

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

No, but You can use __gnu_pbds::tree, for detailts see: http://mirror.codeforces.com/blog/entry/11080

»
7 years ago, # |
  Vote: I like it +21 Vote: I do not like it

you can keep two sets, (in one first N/2, in second another N/2), and easy recalc them after inserting and erasing elements