HDU 5349(2015多校5)-MZL'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>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
const int maxn=1e6+10;
int main()
{
    int n,m,k;
    int Max;
    while(~scanf("%d",&n)){
        priority_queue<int>q;
        Max=-inf;
        while(n--){
            scanf("%d",&m);
            if(m==1){
                scanf("%d",&k);
                q.push(k);
                Max=max(Max,k);
            }
            else if(m==2){
                if(q.empty())
                    continue;
                q.pop();
                if(q.empty())
                    Max=-inf;
            }
            else if(m==3){
                if(q.empty())
                    puts("0");
                else
                    printf("%d\n",Max);
            }
        }
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

HDU 5349(2015多校5)-MZL's simple problem(优先队列)

时间: 2024-10-09 10:12:09

HDU 5349(2015多校5)-MZL's simple problem(优先队列)的相关文章

HDU 5347(2015多校5)-MZL&#39;s chemistry(打表)

题目地址HDU 5347 无脑流神题,自行脑补,百度大法好. #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set> #include <queue> #

HDU 5344(2015多校5)-MZL&#39;s xor(水题)

题目地址:HDU 5344 题意:求所有(Ai+Aj)的异或值. 思路:可以发现(Ai+Aj)和(Aj+Ai)的异或值为0,所以最后只剩下(Ai+Ai). #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm>

HDU 5323(2015多校3)-Solve this interesting problem(dfs+剪枝)

题目地址:HDU 5323 题意:给一个l,r,表示区间[l,r],问是否存在区间为[0,n]的线段树的节点区间为[l,r],如果有求最小的n,如果没有输出-1. 思路:因为L/(R-L+1)<=2015,按照线段树的性质每次分区间序号扩大两倍,所以可以得出差不多有22层,所以用爆搜就可以,由上把[l,r]区间不断扩张,直到满足l==0为止.顺便剪剪枝. #include <stdio.h> #include <math.h> #include <string.h>

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 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 5288||2015多校联合第一场1001题

http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i

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