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 ... 
随机推荐
- 真--可并堆模板--BZOJ2333: [SCOI2011]棘手的操作
			n<=300000个点,开始是独立的,m<=300000个操作: 方法一:单点修改.查询,区间修改.查询?等等等等这里修改是块修改不是连续的啊,那就让他连续呗!具体方法:离线后,每次连接两 ... 
- PatentTips - Hierarchical RAID system including multiple RAIDs
			BACKGROUND OF THE INVENTION The present invention relates to a storage system offering large capacit ... 
- Ubuntu 16.04安装Intel显卡驱动(解决Intel HD Graphics 630显卡驱动问题)
			一般Ubuntu都默认包含了Intel显卡的驱动,如果没有,那么先确定是不是显卡太高,比如I7第7代的CPU核显在Ubuntu 16.04中是没有的,导致画面会很卡,原因是Linux 4.4内核不包含 ... 
- Servlet实现页面重定向
			以下内容引用自http://wiki.jikexueyuan.com/project/servlet/page-redirect.html: 当文档移动到一个新的位置时,通常会使用页面重定向,需要将客 ... 
- 【LeetCode-面试算法经典-Java实现】【067-Add Binary(二进制加法)】
			[067-Add Binary(二进制加法)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given two binary strings, return thei ... 
- Tcl学习之--文件操作
			Tcl中文件名称操作遵循Unix/Linux的命名规范. x/y/z表示x文件夹下的y 子文件夹及y以下的子文件夹z. ~admin/email则表示admin用户的email目录. l file ... 
- Jquery第四课 Javascript中this的使用方法
			thiskeyword的使用 在JavaScript中使用thiskeyword表示调用方法的对象,这与大部分面向对象语言是一样的.可是因为call.apply.bind等函数的影响.我们能够改变th ... 
- Cocos2d-x学习笔记(12)(CCControlSwitch开关、CCControlSlider滑动条、CCControlButtonbutton)
			CCEditBox.CCControlSwitch.CCControlSlider.CCControlColourPicker.CCControlButton等都是Cocos2d-x 2.x的最新UI ... 
- 【C/C++多线程编程之五】pthread线程深入理解
			多线程编程之pthread线程深入理解 Pthread是 POSIX threads 的简称,是POSIX的线程标准. 前几篇博客已经能给你初步的多线程概念.在进一步学 ... 
- 数据结构 - 希尔排序(Shell's Sort) 具体解释 及 代码(C++)
			数据结构 - 希尔排序(Shell's Sort) 具体解释 及 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy/article/details/2 ... 
