题目传送门

  1. /*
  2. 这题可以用stl的mutiset容器方便求解,我对这东西不熟悉,TLE了几次,最后用读入外挂水过。
  3. 题解有O(n)的做法,还以为我是侥幸过的,后来才知道iterator it写在循环内才超时了,囧!
  4. */
  5. /************************************************
  6. Author :Running_Time
  7. Created Time :2015-8-4 12:10:11
  8. File Name :G.cpp
  9. ************************************************/
  10. #include <cstdio>
  11. #include <algorithm>
  12. #include <iostream>
  13. #include <sstream>
  14. #include <cstring>
  15. #include <cmath>
  16. #include <string>
  17. #include <vector>
  18. #include <queue>
  19. #include <deque>
  20. #include <stack>
  21. #include <list>
  22. #include <map>
  23. #include <set>
  24. #include <bitset>
  25. #include <cstdlib>
  26. #include <ctime>
  27. using namespace std;
  28. #define lson l, mid, rt << 1
  29. #define rson mid + 1, r, rt << 1 | 1
  30. typedef long long ll;
  31. const int MAXN = 1e5 + ;
  32. const int INF = 0x3f3f3f3f;
  33. const int MOD = 1e9 + ;
  34. multiset<int>::iterator it;
  35. inline int read(void)
  36. {
  37. int x = , f = ; char ch = getchar ();
  38. while (ch < '' || ch > '') {if (ch == '-') f = -; ch = getchar ();}
  39. while (ch >= '' && ch <= '') {x = x * + ch - ''; ch = getchar ();}
  40. return x * f;
  41. }
  42. int main(void) { //HDOJ 5349 MZL's simple problem
  43. int n;
  44. while (scanf ("%d", &n) == ) {
  45. multiset<int> S;
  46. for (int i=; i<=n; ++i) {
  47. int op, x;
  48. op = read ();
  49. if (op == ) {
  50. x = read ();
  51. S.insert (x);
  52. }
  53. else if (op == ) {
  54. if (S.empty ()) continue;
  55. S.erase (S.begin ());
  56. }
  57. else if (op == ) {
  58. if (S.empty ()) {
  59. puts (""); continue;
  60. }
  61. it = S.end (); it--;
  62. printf ("%d\n", *it);
  63. }
  64. }
  65. }
  66. return ;
  67. }

  1. /************************************************
  2. * Author :Running_Time
  3. * Created Time :2015-8-5 16:42:43
  4. * File Name :G_2.cpp
  5. ************************************************/
  6. #include <cstdio>
  7. #include <algorithm>
  8. #include <iostream>
  9. #include <sstream>
  10. #include <cstring>
  11. #include <cmath>
  12. #include <string>
  13. #include <vector>
  14. #include <queue>
  15. #include <deque>
  16. #include <stack>
  17. #include <list>
  18. #include <map>
  19. #include <set>
  20. #include <bitset>
  21. #include <cstdlib>
  22. #include <ctime>
  23. using namespace std;
  24. #define lson l, mid, rt << 1
  25. #define rson mid + 1, r, rt << 1 | 1
  26. typedef long long ll;
  27. const int MAXN = 1e5 + ;
  28. const int INF = 0x3f3f3f3f;
  29. const int MOD = 1e9 + ;
  30. inline int read(void)
  31. {
  32. int x = , f = ; char ch = getchar ();
  33. while (ch < '' || ch > '') {if (ch == '-') f = -; ch = getchar ();}
  34. while (ch >= '' && ch <= '') {x = x * + ch - ''; ch = getchar ();}
  35. return x * f;
  36. }
  37. int main(void) {
  38. int n; n = read ();
  39. int sz = , mx = -2e9;
  40. for (int i=; i<=n; ++i) {
  41. int op, x; op = read ();
  42. if (op == ) {
  43. x = read ();
  44. sz++; mx = max (mx, x);
  45. }
  46. else if (op == ) {
  47. sz = max (, sz - );
  48. if (!sz) mx = -2e9;
  49. }
  50. else {
  51. if (!sz) puts ("");
  52. else printf ("%d\n", mx);
  53. }
  54. }
  55. return ;
  56. }

标程做法

mutiset HDOJ 5349 MZL's simple problem的更多相关文章

  1. hdoj 5349 MZL's simple problem

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

  2. hdu 5349 MZL's simple problem

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

  3. 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 ...

  4. 【HDOJ】4267 A Simple Problem with Integers

    树状数组.Easy. /* 4267 */ #include <iostream> #include <string> #include <map> #includ ...

  5. POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)

    A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...

  6. POJ 3468 A Simple Problem with Integers(线段树/区间更新)

    题目链接: 传送门 A Simple Problem with Integers Time Limit: 5000MS     Memory Limit: 131072K Description Yo ...

  7. poj 3468:A Simple Problem with Integers(线段树,区间修改求和)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 58269   ...

  8. ACM: A Simple Problem with Integers 解题报告-线段树

    A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...

  9. poj3468 A Simple Problem with Integers (线段树区间最大值)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 92127   ...

随机推荐

  1. UVA 1995 I can guess the structer

    模 拟 /*by SilverN*/ #include<algorithm> #include<iostream> #include<cstring> #inclu ...

  2. PatentTips – EMC Virtual File System

    BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention generally relates to net ...

  3. jquery判断单选按钮radio是否选中的方法

    JQuery控制radio选中和不选中方法总结 一.设置选中方法 复制代码代码如下: $("input[name='名字']").get(0).checked=true; $(&q ...

  4. 创建Django项目(六)——模板

    2013-08-07 22:42:30|           1.设置模板路径         打开 settings.py 文件,修改 TEMPLATE_DIRS 内容,指向模板存放的绝对路径,而不 ...

  5. 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 ...

  6. java常用工具类 - 全角转半角、半角转全角

    全角转半角.半角转全角代码 /** * <PRE> * 提供对字符串的全角->半角,半角->全角转换 * codingwhy.com * </PRE> */ pub ...

  7. WCF - 自定义绑定

    自定义绑定 当系统提供的某个绑定不符合服务的要求时,可使用 CustomBinding 类.所有绑定都是从绑定元素的有序集构造而来的.自定义绑定可以从一组系统提供的绑定元素生成,也可以包含用户定义的自 ...

  8. Spring Boot中微信全局token的缓存实现

    为什么要缓存token? 这里的token指的是微信JSAPI中基础支持的ACCESS_TOKEN,并非网页授权ACCESS_TOKEN.网页授权Token每天的调用次数没有限制,不需要缓存. 接口 ...

  9. python的字典有些类似js对象

    python的字典有些类似js对象 dict1 = {} dict1['one']= '1-one' dict1[2] = '2-tow' tinydict = {'name':'tome','cod ...

  10. Linux学习日志--文件搜索命令

    开头总结: 学习了Linux中的文件搜索命令find和locate,系统搜索命令whereis 和which ,字符串搜索命令grep,find和locate的差别和使用方法格式,什么是path环境变 ...