HDU5349——multiset——MZL'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 <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 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
multiset<int> S;
multiset<int> :: iterator it;
int main(){
    int n;
    int m, k;
    while(~scanf("%d", &n)){
        S.clear();
        while(n--){
            scanf("%d", &m);
            if(m == 1) {
                scanf("%d", &k);
                S.insert(k);
            }
            if(m == 2){
                if(S.empty()) continue;
                S.erase(S.begin());
            }
            else if(m == 3){
                if(S.empty()){
                    printf("0\n");
                    continue;
                }
                else{
                    it = S.end(); it--;
                    printf("%d\n", *it);
                }
            }
        }
    }
        return 0;
}

  

HDU5349——multiset——MZL's simple problem

时间: 2024-12-13 14:48:27

HDU5349——multiset——MZL's simple problem的相关文章

【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

hdoj 5349 MZL&#39;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(

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

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

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&