Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор agrawaltanmay17, история, 5 часов назад, По-английски

I am using distance function in multiset but it requiers a time complexity of O(n) please help me to count the number of elements which are lesser or equal to a perticular element in multiset

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

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

Can't do this in the STL multiset. But you can use the PBDS ordered set. See this blog.

To use the set as a multiset, you can make each element a pair. Something like, instead of inserting $$$a_i$$$ in the set, insert $$$(a_i, i)$$$.