hdoj 5349 MZL's simple problem

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5349

 1 #include<stdio.h>
 2 int main(){
 3     int cnt;
 4     int max;
 5     int N;
 6     int ch;
 7     while(~scanf("%d",&N)){
 8         cnt = 0;
 9         while(N--){
10             scanf("%d",&ch);
11             if(ch==1){
12                 scanf("%d",&ch);
13                 if(cnt==0)
14                     max = ch;
15                 cnt++;
16                 max = ch > max ? ch :max;
17                 continue;
18             }
19             if(ch==2&&cnt!=0)
20                 cnt--;
21             if(ch==3&&cnt!=0)
22                 printf("%d\n",max);
23             if(ch==3&&cnt==0)
24                 printf("0\n");
25         }
26     }
27 }
 1     #include<stdio.h>
 2     #include<cstring>
 3     #include<set>
 4     using namespace std;
 5     int main()
 6     {
 7         multiset<int>s;
 8         int T;
 9         int n, t;
10         while(~scanf("%d",&T)){
11             while(T--){
12                 scanf("%d",&n);
13                 switch(n){
14                     case 1:
15                         scanf("%d",&t);
16                         s.insert(t);
17                         break;
18                     case 2:
19                         if(!s.empty())
20                             s.erase(*s.begin());
21                         break;
22                     case 3:
23                         if(s.empty())
24                             printf("0\n");
25                         else
26                             printf("%d\n",*--s.end());
27                         break;
28                 }
29             }
30         }
31     }

hdoj 5349 MZL's simple problem

时间: 2024-10-12 13:03:47

hdoj 5349 MZL's simple problem的相关文章

mutiset HDOJ 5349 MZL&#39;s simple problem

题目传送门 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

hdu 5349 MZL&#39;s simple problem

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 numbe

【multiset】hdu 5349 MZL&#39;s simple problem

[multiset]hdu 5349 MZL's simple problem 题目链接:hdu 5349 MZL's simple problem 题目大意 n次操作,插入元素.删除最小元素.查询最大元素并输出. C++STL的multiset的使用 set--多元集合(元素不可重复),multiset--可重复元素的多元集合 多元集合(MultiSets)和集合(Sets)相像,只不过支持重复对象.(具体用法请参照set容器) set和multiset内部是以平衡二叉树实现的: 从内部数据结

hdu 5349 MZL&#39;s simple problem(multiset)

代码: #include<set> #include<cstdio> using namespace std; multiset<int> st; int main() { int n; multiset<int>::iterator it; while(scanf("%d",&n)==1) { st.clear(); int k,num; for(int i=0; i<n; i++) { scanf("%d&qu

hdu - 5349 MZL&#39;s simple problem(解题报告)

A - MZL's simple problem Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description A simple problem Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number

HDU 5349 MZL&#39;s simple problem(优先队列)

MZL's simple problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 776    Accepted Submission(s): 375 Problem Description A simple problem Problem Description You have a multiple set,and now

HDU 5349(2015多校5)-MZL&#39;s simple problem(优先队列)

题目地址:HDU 5349 很水的优先队列就能搞好,只不过注意如果2操作结束后的队列为空,那么Max的值为-inf. #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set&

HDU5349——multiset——MZL&#39;s simple problem

http://acm.hdu.edu.cn/showproblem.php?pid=5349 /************************************************ * Author :Powatr * Created Time :2015-8-9 19:37:49 * File Name :F.cpp ************************************************/ #include <cstdio> #include <a

2015 多校 #5 1007 MZL&#39;s simple problem

MZL's simple problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2541    Accepted Submission(s): 694 Problem Description A simple problemProblem DescriptionYou have a multiple set,and now th