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
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | Um_nik | 161 |
1 | cry | 161 |
3 | maomao90 | 160 |
4 | awoo | 158 |
4 | -is-this-fft- | 158 |
6 | atcoder_official | 157 |
7 | nor | 155 |
7 | adamant | 155 |
9 | maroonrk | 152 |
10 | Dominater069 | 149 |
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
Name |
---|
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)$$$.