Is there a way to support duplicates for the Order statistic tree in C++? I have found a way to construct an order statistic set in another question. But it does not support duplicate keys.
For example, if I have s = {1, 1, 2, 2, 3, 4}
. I want s.find_by_order(0) == s.find_by_order(1) == 1
. It seems that if we can use the value of each key as the count and store the total counts in all subtrees in the node, we can achieve that goal. But I don't know how to do that with __gnu_pbds
. Is there a simpler modification of the tree to support that?