博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5349 MZL's simple problem
阅读量:7236 次
发布时间:2019-06-29

本文共 1422 字,大约阅读时间需要 4 分钟。

Problem Description

A simple problem

Problem Description
You have a multiple set,and now there are three kinds of operations:
1 x : add number x to set
2 : delete the minimum number (if the set is empty now,then ignore it)
3 : query the maximum number (if the set is empty now,the answer is 0)

Input

The first line contains a number N (N≤106),representing the number of operations.

Next N line ,each line contains one or two numbers,describe one operation.
The number in this set is not greater than 109.

Output

For each operation 3,output a line representing the answer.

Sample Input

6

1 2
1 3
3
1 3
1 4
3

Sample Output

3

4

题目大意:给你一个数,表示有几行,然后给你一个a和x,如果a等于1的话,就向里面增加一个数,如果a等于2的话 ,就删除集合中最小的一个数,如果等于a==3 的话,就输出最大的数;

解题思路:STL,集合;

具体见代码:

#include 
#include
#include
using namespace std;set
::iterator it;set
s;int main(){ long long n, a, x; scanf("%lld",&n); s.clear(); while(n--) { scanf("%lld",&a); if(a == 1) { scanf("%lld",&x); s.insert(x); } else if(a == 2) { if(!s.empty()) s.erase(s.begin()); } else if(a == 3) { if(s.empty()) puts("0"); else { it=s.end(); it--; printf("%lld\n",*it); } } } return 0;}

转载地址:http://vpwbm.baihongyu.com/

你可能感兴趣的文章
CSS3:用CSS设置多个背景、背景渐变、指定背景大小
查看>>
约束与索引
查看>>
获取页面所有链接的JS
查看>>
leetcode-Palindrome Partitioning II
查看>>
php 下载已经上传好的excel文件出现乱码------解决办法
查看>>
判断单选框选中不成功,$("#xx").attr("checked")undefined
查看>>
React 实现一个漂亮的 Table
查看>>
mysql函数替换域名
查看>>
HDU 1025--LIS算法
查看>>
docker容器访问宿主机IP
查看>>
python- - 函数 - - 迭代器和生成器
查看>>
WebService连接sql serever并使用Android端访问数据
查看>>
无service.bat的tomcat服务怎么设置自启动
查看>>
OpenCV——IplImage
查看>>
源码安装部署redis
查看>>
windows github 下载慢 修改hosts
查看>>
HTML布局规范
查看>>
关于java加法的编写
查看>>
第七周编程总结
查看>>
CocoaPods的安装使用和常见问题
查看>>