Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

agrawaltanmay17's blog

By agrawaltanmay17, history, 3 hours ago, In English

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

»
2 hours ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

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)$$$.