【发布时间】:2020-03-13 00:05:38
【问题描述】:
我有一个多重集,实现如下:
#include <bits/stdc++.h>
using namespace std;
multiset <int> M;
int numunder(int k){
/*this function must return the number of elements smaller than or equal to k
in M (taking multiplicity into account).
*/
}
起初我以为我可以返回 M.upper_bound(k)-M.begin()+1。不幸的是,我们似乎不能像这样减去指针。我们最终不得不实现一个 AVLNodes 结构。有没有办法利用 c++ std 来让它工作?
【问题讨论】: