思路:
两个优先级队列维持,一个容纳较小的数字,一个容纳较大的数字
1.优先级队列的队头在容器尾部
https://blog.csdn.net/weixin_36888577/article/details/79937886
2.只要有一个操作数是double,商就是double
priority_queue<int> big;//大顶堆,默认priority_queue<int, vector<int>, greater<int> > small;//小顶堆void Insert(int num){if(big.empty() || num <= big.top())big.push(num);else small.push(num);if(big.size() > small.size() + 1){small.push(big.top());big.pop();}if(small.size() > big.size()){big.push(small.top());small.pop();}}double GetMedian(){int len = small.size() + big.size();if(len % 2 == 1)return big.top();else return (small.top() + big.top()) / 2.0;}
