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 ...
随机推荐
- 【中文排序】mysql order by 中文排序
1. 在MySQL中,我们经常会对一个字段进行排序查询,但进行中文排序和查找的时候,对汉字的排序和查找结果往往都是错误的. 这种情况在MySQL的很多版本中都存在. 如果这个问题不解决,那么MySQL ...
- Linux下汇编语言学习笔记36 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Thinkphp5.0 视图view取值
Thinkphp5.0 视图view取值 <!-- 获取控制器传递的变量 --> <li>{$age}</li> <!-- 获取服务器的信息 --> & ...
- POJ2367 拓扑排序 裸题 板子题
http://poj.org/problem?id=2367 队列版 #include <stdio.h> #include <math.h> #include <str ...
- spring SSH整合
1 导入三大框架依赖的包: 2 配置web.xml: 增加spring的OpenSessionInView过滤器让Spring管理Session保证Session在一个完整的请求过程是开着的,要配置S ...
- 【c++】【转】c++中的explicit关键字
http://www.cnblogs.com/chio/archive/2007/09/17/895263.html c++中的explicit关键字用来修饰类的构造函数,表明该构造函数是显式(调用) ...
- MapReduce Cross 示例
MapReduce Cross 示例 package com.bsr.cross; import java.io.IOException; import org.apache.hadoop.conf. ...
- 005 EIGRP
Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(co ...
- 手游产品经理初探(二)从营销角度看loading界面
近期開始写产品相关的专题,准备从细节入手去思考.总结一些不为人注意的细节地方. 今天给大家分享的是游戏里面都有的loading界面. 还是从几个在Facebook上排名靠前的Casino游戏的load ...
- Android关于Task的一些实践之SingleTask, SingleInstance和TaskAffinity
上一篇文章粗略地介绍了一下关于Android中Task的基本知识.只是实践才是检验真理的唯一标准,所以.今天就来试验一下Task中的launchMode是否真的实现了文档所说的那样. 首先.定义三个A ...