HDU 5349 (2015 + school 5)-mzl ' s simple problem (priority queue)

Source: Internet
Author: User

Title Address: HDU 5349
The priority queue of water is good, but note that if the queue after the 2 operation is empty, the value of Max is-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 LongLL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-6;Const intmaxn=1e6+Ten;intMain () {intN,m,k;intMax; 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;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 5349 (2015 + school 5)-mzl ' s simple problem (priority queue)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.