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

三个操作,删除最小,查询最大,插入

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
typedef long long ll;
using namespace std; int main()
{
int n;
while(scanf("%d",&n)==1)
{
int x;
ll q, tmax = -1000000100;
int sum = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d",&x);
if(sum==0)
tmax = -1000000100;
if(x == 1)
{
scanf("%I64d",&q);
if(q >= tmax)
tmax = q;
sum++;
}
if(x == 2)
{
if(sum>0)
sum--;
}
if(x == 3)
{
if(sum>0)
printf("%I64d\n",tmax);
else printf("0\n");
}
}
} return 0;
}

  

2015 多校联赛 ——HDU5349(水)的更多相关文章

  1. 2015 多校联赛 ——HDU5400(水)

    Sample Input 5 2 -2 0 2 0 -2 0 5 2 3 2 3 3 3 3   Sample Output 12 5 求最多多少序列满足,前半部分满足d(j+1) = d(j)+d1 ...

  2. 2015 多校联赛 ——HDU5344(水)

    Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to ...

  3. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  4. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  5. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  6. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  7. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  8. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  9. 2015 多校联赛 ——HDU5319(模拟)

    Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su ...

随机推荐

  1. 201621123040 《Java程序设计》第1周学习总结

    1.本周学习总结 关键词 JAVA概述 HelloWorld JDK JRE JVM JAVA基础语法 相关联系 通过一周的学习,我对JAVA有了初步的了解,JAVA是一种优秀的跨平台编写代码的应用平 ...

  2. 20162323周楠《Java程序设计与数据结构》第五周总结

    20162323周楠 2016-2017-2 <程序设计与数据结构>第五周学习总结 教材学习内容总结 1.面向对象软件设计的基本部分是确定程序中应该创建哪些类: 2.面向对象程序设计的核心 ...

  3. C++类型萃取

    stl中的迭代器和C++中的类型萃取: http://www.itnose.net/detail/6487058.html 赐教!

  4. Argparse简易教程

    Argparse简易教程 原文:Argparse Tutorial 译者:likebeta 本教程是对于Python标准库中推荐使用的命令行解析模块argparse的简单介绍. PS:还有其他两个模块 ...

  5. Python之旅.第四章.模块与包.总结(未完待遇)

    一.模块 模块: 一系列功能的集合体,在python中一个py文件就是一个模块,模块名就是py文件的文件名: 模块的好处: 1.减少重复的代码 2.拿来主义 定义模块: 就是创建一个py文件: 使用模 ...

  6. Appium+python测试app实例

    Appium和selenium差不到,只是一个用于测web,一个用于测APP.下面记录一下我搭的测试框架,同样是基于PO模式,用的unittest. 最后测试报告如下: 1.1      代码结构 这 ...

  7. Jetty入门(1-1)Jetty入门教程

    一.Jetty是什么? 1.Jetty 是一个Java语言编写的,开源的Servlet容器和应用服务器. Jetty 极度轻量级.高便携性.功能强大.灵活和扩展性好,而且支持各种技术如SPDY.Web ...

  8. 阿里安全归零实验室招聘各路大牛!offer好说!

    阿里安全归零实验室成立于2017年11月,致力于对黑灰产技术的研究.实验室的愿景是通过技术手段解决当前日益严重的网络违规和网络犯罪问题,为阿里新经济体保驾护航. 实验室与寄生在阿里生态经济体的黑灰产直 ...

  9. python中 functools模块 闭包的两个好朋友partial偏函数和wraps包裹

    前一段时间学习了python当中的装饰器,主要利用了闭包的原理.后来呢,又见到了python当中的functools模块,里面有很多实用的功能.今天我想分享一下跟装饰器息息相关的两个函数partial ...

  10. RxJava系列番外篇:一个RxJava解决复杂业务逻辑的案例

    之前写过一系列RxJava的文章,也承诺过会尽快有RxJava2的介绍.无奈实际项目中还未真正的使用RxJava2,不敢妄动笔墨.所以这次还是给大家分享一个使用RxJava1解决问题的案例,希望对大家 ...