HDOJ 5349 MZL's simple problem 【set】
2015-08-04 19:25
302 查看
HDOJ 5349 MZL’s simple problem 【set】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5349set常用场景: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++<<"\t"; 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\n"); else printf("%d\n", *--s.end()); // end为最后一个元素的下一个指针 } } return 0; }
相关文章推荐
- wikioi 1294 全排列
- HDOJ 5349 MZL's simple problem 【set】
- HDU 3720 Arranging Your Team
- HDOJ 1050 Moving Tables(贪心)
- 设计模式——适配器模式
- 可变参数
- css3属性笔记
- CSS理解样式表层叠
- Struts2工作原理
- linux 把文件安装到指定路径
- 100分程序员的8个习惯
- [MetaHook] Load DTX texture to OpenGL
- 用数组求一组数的最大值、最小值和平均值,并求有多少个数超过平均数
- Runnable和Thread基础---多线程学习笔记(二)
- Runnable和Thread基础---多线程学习笔记(二)
- HDU 1021 Fibonacci Again
- c++派生类和基类的构造函数和析构函数
- android 磨砂玻璃效果
- Objective-C语法之Objective-C语言和IOS系统(简介,语法,系统结构)
- MySQL谨慎使用"replace into"