MZL's simple problem

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 740    Accepted Submission(s): 357

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
 
Source
 
解题:由于我们只需要查询最大值,所以最大值总是最后一个被删的,如果当前集合只有一个元素,那么肯定是删最大的元素了,否则,随便删就是了,不影响最大值
 
 #include <bits/stdc++.h>
using namespace std;
int main() {
int n,op,val;
while(~scanf("%d",&n)) {
int sz = ,maxval = INT_MIN;
while(n--) {
scanf("%d",&op);
switch(op) {
case :
scanf("%d",&val);
maxval = max(val,maxval);
sz++;
break;
case :
sz = max(,sz-);
if(!sz) maxval = INT_MIN;
break;
case :
printf("%d\n",sz?maxval:);
break;
default:
;
}
}
}
return ;
}

2015 Multi-University Training Contest 5 hdu 5349 MZL's simple problem的更多相关文章

  1. hdu 5349 MZL's simple problem

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5349 MZL's simple problem Description A simple proble ...

  2. mutiset HDOJ 5349 MZL's simple problem

    题目传送门 /* 这题可以用stl的mutiset容器方便求解,我对这东西不熟悉,TLE了几次,最后用读入外挂水过. 题解有O(n)的做法,还以为我是侥幸过的,后来才知道iterator it写在循环 ...

  3. 2015 Multi-University Training Contest 5 hdu 5352 MZL's City

    MZL's City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  4. 2015 Multi-University Training Contest 5 hdu 5348 MZL's endless loop

    MZL's endless loop Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...

  5. 2015 Multi-University Training Contest 3 hdu 5323 Solve this interesting problem

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

  6. hdoj 5349 MZL's simple problem

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5349 #include<stdio.h> int main(){ int cnt; int ...

  7. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  8. 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!

    Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID:  ...

  9. 2015 Multi-University Training Contest 8 hdu 5385 The path

    The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...

随机推荐

  1. 工具-VMWARE技巧-桥接连外网-WIN7

    使用虚拟机wmware如何连接宿主主机 最简单的方法,使用直接连接主机的模式,然后把宿主机的IP更改为和虚拟机同一个网段的机器就行 但是既要上网,有要连接虚拟机,就需要使用桥接,在编辑->虚拟网 ...

  2. wordpress迁移以及遇到的一些问题[mysql备份导入导出][固定链接404]

    总的问题有两个,一是apache的配置,二是mysql的导出和导入.以及迁移后遇到的一些问题解决过程和方法. A机器为老server.B为新server,A机器使用Appserv,B使用wmap,在配 ...

  3. Unity3D_c#脚本注意要点

    1. Inherit from MonoBehaviour 继承自MonoBehaviour All behaviour scripts must inherit from MonoBehaviour ...

  4. Codeforces Round #260 (Div. 1) 455 A. Boredom (DP)

    题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory l ...

  5. 例说Linux内核链表(三)

    经常使用的linux内核双向链表API介绍 linux link list结构图例如以下: 内核双向链表的在linux内核中的位置:/include/linux/list.h 使用双向链表的过程,主要 ...

  6. wifi破解不是真黑客不靠谱?

    Wifi破解神器骗局:摆地摊+网络兜售 近日,"万能wifipassword破解器"风靡全国地摊.各地小贩開始兜售这样的蹭网卡.声称可破解各种wifipassword,当场測试也是 ...

  7. php生产随机数

    php生产随机数 要求 生产三种随机数 1.全数字 2.全字母,大小写 3.数字和大小写字母 代码 <?php class RandString{ //这个属性表示我们随机数的长度,也就是个数 ...

  8. lightoj--1294--Largest Box(三分)

    Largest Box Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Sta ...

  9. SpringCloud微服务Docker部署

    前两写了两篇,都是为SpringCloud+Docker部署做准备,在部署的时候,不同服务器,不同的Docker容器之间的通信,还好没有掉到坑里去,在公司里用了新技术,还是很开心的,小有成就感,之前一 ...

  10. Redis的配置文件详解

    daemonize:如需要在后台运行,把该项的值改为yes pdifile:把pid文件放在/var/run/redis.pid,可以配置到其他地址 bind:指定redis只接收来自该IP的请求,如 ...