2015 多校联赛 ——HDU5349(水)
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)
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.
1 2
1 3
3
1 3
1 4
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(水)的更多相关文章
- 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 ...
- 2015 多校联赛 ——HDU5344(水)
Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to ...
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2015 多校联赛 ——HDU5325(DFS)
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5316(线段树)
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...
- 2015 多校联赛 ——HDU5323(搜索)
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
随机推荐
- Twisted UDP编程技术
实战演练1:普通UDP UDP是一种无连接对等通信协议,没有服务器和客户端概念,通信的任何一方均可通过通信原语直接和其他方通信 1.相对于TCP,UDP编程只需定义DatagramProtocol子类 ...
- :after/:before使用技巧
伪类:after/:before基本使用 div:before{ content:'';//必须要写,没写则伪元素无效 display:; position:''; ... } //在一个div子元素 ...
- .net mvc 利用分部视图局部刷新.
页面利于$.Ajax: $(function(){ $("#btnpartview").click(function () { var model = []; model.push ...
- php代码开启缓冲的使用方法
php可以开启缓冲区,就是将内容放到缓冲区,再决定什么时候发送给浏览器. 感谢:http://www.jb51.net/article/38964.htm 解析PHP中ob_start()函数的用法 ...
- python全栈开发-logging模块(日记专用)
一.概述 很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误.警告等信息输出,python的logging模块提供了标准的日志接口,你可以通过它存储各种格式的日志,l ...
- JavaScript查找数组中最大的值
// 查找一个数组中最大的数 // 定义一个方法 searchMax function searchMax(arr) { // 声明一个变量MaxNumber假设为数组中最大的值arr[0]; var ...
- PHP trait
ps:由于PHP是单继承的,无法继承多个类所以可以用triat(关键字,特性)来命名达到子类继承多个父类的效果:暂且理解为类吧.class = trait <?php trait A { pub ...
- Mego开发文档 - 保存关系数据
保存关系数据 由于没有对象的更改跟踪,因此关系的操作需要开发者明确指定,在成功执行后Mego会影响到相应的关系属性中. 添加关系 在以下示例中如果成功执行则source的Customer属性会变为ta ...
- J2ee入门:servlet-mapping的映射配置
<servlet-mapping>元素在Servlet和URL样式之间定义一个映射.它包含了两个子元素<servlet- name>和<url-pattern> & ...
- 2.x与3.x差异、条件语句、数据类型、其他
一.输入(raw_input)=====>python2.x版本 #!/usr/bin/env python # -*- coding: utf-8 -*- # 将用户输入的内容赋值给 name ...