More than 2015 school #5 1007 MZL ' s simple problem

Source: Internet
Author: User

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 Descriptiona Simple problem
Problem Description
You has a multiple set,and now there is 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 number (if the set is an empty now,the answer is 0)

Inputthe First line contains a numberN(N≤6 ), representing the number of operations.
NextN line contains one or both Numbers,describe one operation.
The number in this set is not greater than 9.

Outputfor Operation 3,output A line representing the answer.

Sample Input61 21 331 31 43

Sample Output34 water problem. Simulation is good. Say puts () is not very fast ... The results were also tle once. and change it to printf.
1 /*************************************************************************2 > File name:code/multi/#5/1007.cpp3 > Author:111qqz4 > Email: [Email protected]5 > Created time:2015 August 04 Tuesday 12:39 42 seconds6  ************************************************************************/7 8#include <iostream>9#include <iomanip>Ten#include <cstdio> One#include <algorithm> A#include <cmath> -#include <cstring> -#include <string> the#include <map> -#include <Set> -#include <queue> -#include <vector> +#include <stack> - #defineY0 ABC111QQZ + #defineY1 HUST111QQZ A #defineYn hez111qqz at #defineJ1 CUTE111QQZ - #defineTM CRAZY111QQZ - #defineLR DYING111QQZ - using namespacestd; - #defineREP (i, n) for (int i=0;i<int (n); ++i) -typedefLong LongLL; intypedef unsignedLong LongULL; - Const intINF =0x7fffffff; to Const intn=1e6+7; +multiset<int>se; -multiset<int>:: iterator it; the intMain () * { $     intN;Panax Notoginseng     intcmd; -     intx; thescanf"%d",&n); +      for(inti =0;  I < n; i++) A     { thescanf"%d",&cmd); +     if(cmd==1) -     { $scanf"%d",&x); $ Se.insert (x); -     } -     if(cmd==2&&!se.empty ()) the     { - se.erase (Se.begin ());Wuyi     } the     if(cmd==3) -     { Wu         if(Se.empty ()) -         { Aboutprintf"0\n"); $         } -         Else -         { -it =se.end (); Ait--; +printf"%d\n",*it); the         } -     } $     } the     return 0; the}
View Code

More than 2015 school #5 1007 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.