mutiset HDOJ 5349 MZL's simple problem
- /*
- 这题可以用stl的mutiset容器方便求解,我对这东西不熟悉,TLE了几次,最后用读入外挂水过。
- 题解有O(n)的做法,还以为我是侥幸过的,后来才知道iterator it写在循环内才超时了,囧!
- */
- /************************************************
- Author :Running_Time
- Created Time :2015-8-4 12:10:11
- File Name :G.cpp
- ************************************************/
- #include <cstdio>
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <cstring>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <list>
- #include <map>
- #include <set>
- #include <bitset>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- #define lson l, mid, rt << 1
- #define rson mid + 1, r, rt << 1 | 1
- typedef long long ll;
- const int MAXN = 1e5 + ;
- const int INF = 0x3f3f3f3f;
- const int MOD = 1e9 + ;
- multiset<int>::iterator it;
- inline int read(void)
- {
- int x = , f = ; char ch = getchar ();
- while (ch < '' || ch > '') {if (ch == '-') f = -; ch = getchar ();}
- while (ch >= '' && ch <= '') {x = x * + ch - ''; ch = getchar ();}
- return x * f;
- }
- int main(void) { //HDOJ 5349 MZL's simple problem
- int n;
- while (scanf ("%d", &n) == ) {
- multiset<int> S;
- for (int i=; i<=n; ++i) {
- int op, x;
- op = read ();
- if (op == ) {
- x = read ();
- S.insert (x);
- }
- else if (op == ) {
- if (S.empty ()) continue;
- S.erase (S.begin ());
- }
- else if (op == ) {
- if (S.empty ()) {
- puts (""); continue;
- }
- it = S.end (); it--;
- printf ("%d\n", *it);
- }
- }
- }
- return ;
- }
- /************************************************
- * Author :Running_Time
- * Created Time :2015-8-5 16:42:43
- * File Name :G_2.cpp
- ************************************************/
- #include <cstdio>
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <cstring>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <list>
- #include <map>
- #include <set>
- #include <bitset>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- #define lson l, mid, rt << 1
- #define rson mid + 1, r, rt << 1 | 1
- typedef long long ll;
- const int MAXN = 1e5 + ;
- const int INF = 0x3f3f3f3f;
- const int MOD = 1e9 + ;
- inline int read(void)
- {
- int x = , f = ; char ch = getchar ();
- while (ch < '' || ch > '') {if (ch == '-') f = -; ch = getchar ();}
- while (ch >= '' && ch <= '') {x = x * + ch - ''; ch = getchar ();}
- return x * f;
- }
- int main(void) {
- int n; n = read ();
- int sz = , mx = -2e9;
- for (int i=; i<=n; ++i) {
- int op, x; op = read ();
- if (op == ) {
- x = read ();
- sz++; mx = max (mx, x);
- }
- else if (op == ) {
- sz = max (, sz - );
- if (!sz) mx = -2e9;
- }
- else {
- if (!sz) puts ("");
- else printf ("%d\n", mx);
- }
- }
- return ;
- }
标程做法
mutiset HDOJ 5349 MZL's simple problem的更多相关文章
- hdoj 5349 MZL's simple problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5349 #include<stdio.h> int main(){ int cnt; int ...
- hdu 5349 MZL's simple problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5349 MZL's simple problem Description A simple proble ...
- 2015 Multi-University Training Contest 5 hdu 5349 MZL's simple problem
MZL's simple problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- 【HDOJ】4267 A Simple Problem with Integers
树状数组.Easy. /* 4267 */ #include <iostream> #include <string> #include <map> #includ ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- POJ 3468 A Simple Problem with Integers(线段树/区间更新)
题目链接: 传送门 A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Description Yo ...
- poj 3468:A Simple Problem with Integers(线段树,区间修改求和)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 58269 ...
- ACM: A Simple Problem with Integers 解题报告-线段树
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
- poj3468 A Simple Problem with Integers (线段树区间最大值)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 92127 ...
随机推荐
- UVA 1995 I can guess the structer
模 拟 /*by SilverN*/ #include<algorithm> #include<iostream> #include<cstring> #inclu ...
- PatentTips – EMC Virtual File System
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention generally relates to net ...
- jquery判断单选按钮radio是否选中的方法
JQuery控制radio选中和不选中方法总结 一.设置选中方法 复制代码代码如下: $("input[name='名字']").get(0).checked=true; $(&q ...
- 创建Django项目(六)——模板
2013-08-07 22:42:30| 1.设置模板路径 打开 settings.py 文件,修改 TEMPLATE_DIRS 内容,指向模板存放的绝对路径,而不 ...
- Minimum Depth of Binary Tree(二叉树DFS)
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- java常用工具类 - 全角转半角、半角转全角
全角转半角.半角转全角代码 /** * <PRE> * 提供对字符串的全角->半角,半角->全角转换 * codingwhy.com * </PRE> */ pub ...
- WCF - 自定义绑定
自定义绑定 当系统提供的某个绑定不符合服务的要求时,可使用 CustomBinding 类.所有绑定都是从绑定元素的有序集构造而来的.自定义绑定可以从一组系统提供的绑定元素生成,也可以包含用户定义的自 ...
- Spring Boot中微信全局token的缓存实现
为什么要缓存token? 这里的token指的是微信JSAPI中基础支持的ACCESS_TOKEN,并非网页授权ACCESS_TOKEN.网页授权Token每天的调用次数没有限制,不需要缓存. 接口 ...
- python的字典有些类似js对象
python的字典有些类似js对象 dict1 = {} dict1['one']= '1-one' dict1[2] = '2-tow' tinydict = {'name':'tome','cod ...
- Linux学习日志--文件搜索命令
开头总结: 学习了Linux中的文件搜索命令find和locate,系统搜索命令whereis 和which ,字符串搜索命令grep,find和locate的差别和使用方法格式,什么是path环境变 ...