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. nyoj 120 建边构强连通

    #include<stdio.h> #include<string.h> #include<queue> using namespace std; #define ...

  2. [SharePoint][SharePoint Designer 入门经典]Chapter13 客户端JavaScript编程

    1.创建客户对象模型的页面 2.使用CAML从SPS中取得数据 3.创建更新删除列表项目 4.为ribbon添加项目

  3. POI进行ExcelSheet的拷贝

    POI进行ExcelSheet的拷贝 学习了:http://www.360doc.com/content/17/0508/20/42823223_652205632.shtml,这个也需要改改 这个: ...

  4. 近200篇机器学习&amp;深度学习资料分享

    编者按:本文收集了百来篇关于机器学习和深度学习的资料,含各种文档,视频,源码等.并且原文也会不定期的更新.望看到文章的朋友能够学到很多其它. <Brief History of Machine ...

  5. oracle rac下调节redo log file 文件大小

    rac下调节redo log file 文件大小 (1)查看当前日志信息: select * from v$logfile; (步骤2中得路径能够在这里MEMBER列看到,redo文件名称自己命名.比 ...

  6. js 数组克隆

    在JS中,对于对象类型的变量的引用是通过类似C之类的"指针"的方式来操作的,及假设多个变量引用同一个对象,则随意一个变量对对象的操作都会影响到其他的变量. 这个可能不是非常明确,以 ...

  7. 广东工业大学2016校赛决赛-网络赛 1174 Problem F 我是好人4 容斥

    Problem F: 我是好人4 Description 众所周知,我是好人!所以不会出太难的题,题意很简单 给你n个数,问你1000000000(含1e9)以内有多少个正整数不是这n个数任意一个的倍 ...

  8. zzulioj--1613--少活一年?(稍微有点坑,水!)

    1613: 少活一年? Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 344  Solved: 70 SubmitStatusWeb Board De ...

  9. vmvare如何安装xp虚拟机

    http://jingyan.baidu.com/article/a681b0ded8e25e3b19434640.html 一直以来,许多的朋友都不熟悉怎么安装在虚拟机上装windows系统 200 ...

  10. 【转】SQL语句删除和添加外键、主键

    --删除外键 语法:alter table 表名 drop constraint 外键约束名 如: alter table Stu_PkFk_Sc drop constraint FK_s alter ...