思路:
    两个优先级队列维持,一个容纳较小的数字,一个容纳较大的数字

    1.优先级队列的队头在容器尾部
    image.png

    https://blog.csdn.net/weixin_36888577/article/details/79937886

    2.只要有一个操作数是double,商就是double

    1. priority_queue<int> big;//大顶堆,默认
    2. priority_queue<int, vector<int>, greater<int> > small;//小顶堆
    3. void Insert(int num)
    4. {
    5. if(big.empty() || num <= big.top())big.push(num);
    6. else small.push(num);
    7. if(big.size() > small.size() + 1){
    8. small.push(big.top());
    9. big.pop();
    10. }
    11. if(small.size() > big.size()){
    12. big.push(small.top());
    13. small.pop();
    14. }
    15. }
    16. double GetMedian()
    17. {
    18. int len = small.size() + big.size();
    19. if(len % 2 == 1)return big.top();
    20. else return (small.top() + big.top()) / 2.0;
    21. }