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. django搭建web (三) admin.py -- 待续

    demo 关于模型myQuestion,myAnswer将在后述博客提及 # -*- coding: utf-8 -*- from __future__ import unicode_literals ...

  2. Binary Tree Xorder Traversal

     * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeN ...

  3. 微信公众号Markdown编辑器, 适合代码排版

    随着大家都转战微信公众平台,如何快速的编写文章就摆在了首要位置.不可否认,使用微信自带的编辑器可以做出好看的排版,甚至用第三方编辑器有更多的模板.但是,这些全部都需要手动的调整.本来公众平台就算是自媒 ...

  4. Spring邮件发送1

    注意:邮件发送code中,邮件服务器的申请和配置是比较主要的一个环节,博主这里用的是QQ的邮件服务器.有需要的可以谷歌.百度查下如何开通. 今天看了下Spring的官方文档的邮件发送这一章节.在这里记 ...

  5. linux下安装配置jdk(解压版)

    在linux下登录oracle官网,下载解压版jdk    传送门 系统默认下载到"下载"目录中 创建要将该文件解压的文件夹: 其中 -p 参数代表递归创建文件夹(可以创建多级目录 ...

  6. angular2 学习笔记 ( unit test 单元测试 )

    第一次写单元测试. 以前一直都有听说 TDD 的事情. 今天总算是去尝试了一下. 先说说 TDD 的想法, 是这样的, 开发项目的流程 : 确定需求 -> 写类,接口,方法的名字(不写具体实现代 ...

  7. 新概念英语(1-5)Nice to meet you.

    Is Chang-woo Chinese? Blake:Good morning. B:Good morning, Mr Blake. Blake:This is Miss Sophie Dupont ...

  8. Django中自定义过滤器的使用

    我在这里做的是: 从数据库查出id递增的一些信息,展示在前台. 编写一个过滤器判断查出数据的id是偶数的返回True 奇数返回False 1 创建项目,创建应用,注册应用,配置settings.py文 ...

  9. Python操作SQLAchemy

    如果对代码不懂就看这个:http://www.cnblogs.com/jixuege-1/p/6272888.html 本篇对于Python操作MySQL主要使用两种方式: 原生模块 pymsql O ...

  10. hash详解

    首先介绍一下hash? 事实上是一种叫做蛤丝的病毒 hash的做法: 首先设一个进制数base,并设一个模数mod 而哈希其实就是把一个数转化为一个值,这个值是base进制的,储存在哈希表中,注意一下 ...