zoukankan      html  css  js  c++  java
  • HDOJ 5349 MZL's simple problem 【set】

    HDOJ 5349 MZL’s simple problem 【set】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5349


    set常用场景:operator选择功能实现

    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cstring>
    #include<set>
    using namespace std;
    int N;
    int op, opn;
    multiset<int> s; // 元素可重复
    multiset<int>::iterator it;
    
    void output(){
        it = s.begin();
        while(it != s.end())
            cout<<*it++<<"	";
        cout<<endl;
    }
    
    int main(){
        scanf("%d", &N);
        while(N--){
            scanf("%d", &op);
            if(op == 1){
                scanf("%d", &opn);
                s.insert(opn);
                //output();
            }
            else if(op == 2){
                if(!s.empty()){
                    s.erase(*s.begin());
                    //output();
                }
            }
            else{
                if(s.empty())
                    printf("0
    ");
                else
                    printf("%d
    ", *--s.end()); // end为最后一个元素的下一个指针
            }
        }
    
        return 0;
    }
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    TestNG
    K近邻算法
    Python解决乱码问题
    Log4J 配置
    多线程死锁
    hadooplzo安装出错的解决方法
    B树
    设计模式
    整数序列化
    Maven
  • 原文地址:https://www.cnblogs.com/miaowTracy/p/4836770.html
Copyright © 2011-2022 走看看