Mutiset hdoj 5349 MZL ' s simple problem

Source: Internet
Author: User
Tags bitset cmath

Topic Portal

1 /*2 This problem can be easily solved with STL mutiset container, I am not familiar with this thing, tle several times, finally used to read into the plug water. 3 the solution has O (n) practice, still think I was lucky, later only know iterator it write in the loop just timed out, embarrassed! 4 */5 /************************************************6 Author:running_time7 Created time:2015-8-4 12:10:118 File name:g.cpp9 ************************************************/Ten  One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in  - #defineLson L, Mid, RT << 1 to #defineRson mid + 1, R, RT << 1 | 1 +typedefLong Longll; - Const intMAXN = 1e5 +Ten; the Const intINF =0x3f3f3f3f; * Const intMOD = 1e9 +7; $multiset<int>:: iterator it;Panax Notoginseng  -InlineintReadvoid) the { +     intx =0, F =1;CharCH =GetChar (); A      while(Ch <'0'|| CH >'9')    {if(ch = ='-') F =-1; CH =GetChar ();} the      while(Ch >='0'&& CH <='9') {x = x *Ten+ CH-'0'; CH =GetChar ();} +     returnX *F; - } $  $ intMainvoid)    {//hdoj 5349 MZL ' s simple problem -     intN; -      while(SCANF ("%d", &n) = =1)   { themultiset<int>S; -          for(intI=1; i<=n; ++i) {Wuyi             intop, x;  theOP =read (); -             if(OP = =1)    { Wux =read (); - S.insert (x); About             } $             Else if(OP = =2)   { -                 if(S.empty ())Continue; - s.erase (S.begin ()); -             } A             Else if(OP = =3)   { +                 if(S.empty ()) { thePuts ("0");Continue; -                 } $it = S.end (); it--; theprintf ("%d\n", *it); the             } the         } the     } -  in     return 0; the}
1 /************************************************2 * Author:running_time3 * Created time:2015-8-5 16:42:434 * File Name:G_2.cpp5  ************************************************/6 7#include <cstdio>8#include <algorithm>9#include <iostream>Ten#include <sstream> One#include <cstring> A#include <cmath> -#include <string> -#include <vector> the#include <queue> -#include <deque> -#include <stack> -#include <list> +#include <map> -#include <Set> +#include <bitset> A#include <cstdlib> at#include <ctime> - using namespacestd; -  - #defineLson L, Mid, RT << 1 - #defineRson mid + 1, R, RT << 1 | 1 -typedefLong Longll; in Const intMAXN = 1e5 +Ten; - Const intINF =0x3f3f3f3f; to Const intMOD = 1e9 +7; +  -InlineintReadvoid) the { *     intx =0, F =1;CharCH =GetChar (); $      while(Ch <'0'|| CH >'9')    {if(ch = ='-') F =-1; CH =GetChar ();}Panax Notoginseng      while(Ch >='0'&& CH <='9') {x = x *Ten+ CH-'0'; CH =GetChar ();} -     returnX *F; the } +  A intMainvoid)    { the     intN n =read (); +     intSZ =0, mx =-2e9; -      for(intI=1; i<=n; ++i) { $         intOP, x; OP =read (); $         if(OP = =1)    { -x =read (); -sz++; MX =max (MX, x); the         } -         Else if(OP = =2)   {WuyiSZ = max (0, Sz-1); the             if(!sz) MX =-2e9; -         } Wu         Else    { -             if(!sz) puts ("0"); About             Elseprintf ("%d\n", MX); $         } -     } -  -     return 0; A}
Nominal procedure

Mutiset hdoj 5349 MZL ' s simple problem

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.