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

Автор prodipdatta7, 5 лет назад, По-английски

How can I solve this problem? Any kind of help regarding this problem will be appreciated.

The abridged problem is:
Given a sequence of numbers. You have to perform 3 types of queries.

1 V: Add V to the end of the sequence.
2: remove an element from the end of the sequence.
3 l r: Find the K'th largest number in the range.
`

It is guaranteed that 1 <= l <= r <= the total number of elements in the current sequence.
Problem link

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

»
5 лет назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

you can use persistence segment tree.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You can use Merge Sort Tree.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

May be there are other solutions, but there is a relatively new and less used data structure called Wavelet Tree that supports all of these operations. I don't know how easy it is to use because I haven't implemented it yet. But if you are interested you can read about it in this IOI journal.