zoukankan      html  css  js  c++  java
  • 模板

    #include<bits/stdc++.h>
    using namespace std;
    
    struct Opposite_Heap{
        //top_heap has the min element,bottom heap has the max element
    
        priority_queue<int,vector<int>,less<int> > top_heap;
        priority_queue<int,vector<int>,greater<int> > bottom_heap;
    
        int k;
    
        Opposite(){k=0;}
    
        void add(int value){
            /*change k*/
            if(top_heap.size()<=i){
                top_heap.push(value);
            }
            else{
                if(value<top_heap.top()){
                    bottom_heap.push(top_heap.top());
                    top_heap.pop();
                    top_heap.push(value);
                }
                else{
                    bottom_heap.push(value);
                }
            }
            /*change k*/
        }
    
        int get(){
            /*change k*/
            /*while(top_heap.size()<=k&&!bottom_heap.empty()){
                top_heap.push(bottom_heap.top());
                bottom_heap.pop();
            }*/
    
            int t=top_heap.top();
    
            /*change k*/
            while(top_heap.size()<=k&&!bottom_heap.empty()){
                top_heap.push(bottom_heap.top());
                bottom_heap.pop();
            }
            return t;
        }
    };
  • 相关阅读:
    萨卡斯指法
    香港保险
    数据分析,了解行业
    数据分析师
    黑盒测试方法
    web系统的常用功能测试
    linux-磁盘问题
    mysql连表查询
    mysql模糊查询
    MySQL 数据类型
  • 原文地址:https://www.cnblogs.com/Yinku/p/10498815.html
Copyright © 2011-2022 走看看