码迷,mamicode.com
首页 > 其他好文 > 详细

2015 多校 #5 1007 MZL's simple problem

时间:2015-08-07 19:12:18      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:

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 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 number (if the set is empty now,the answer is 0)
 

 

Input
The first line contains a number N (N106),representing the number of operations.
Next N line ,each line contains one or two numbers,describe one operation.
The number in this set is not greater than 109.
 

 

Output
For each operation 3,output a line representing the answer.
 

 

Sample Input
6 1 2 1 3 3 1 3 1 4 3
 

 

Sample Output
3 4
 
水题。
模拟就好。
话说puts() 不是挺快的。。。
结果还tle了一次。
然后改成 printf 就A了。。。
技术分享
 1 /*************************************************************************
 2     > File Name: code/multi/#5/1007.cpp
 3     > Author: 111qqz
 4     > Email: rkz2013@126.com 
 5     > Created Time: 2015年08月04日 星期二 12时39分42秒
 6  ************************************************************************/
 7 
 8 #include<iostream>
 9 #include<iomanip>
10 #include<cstdio>
11 #include<algorithm>
12 #include<cmath>
13 #include<cstring>
14 #include<string>
15 #include<map>
16 #include<set>
17 #include<queue>
18 #include<vector>
19 #include<stack>
20 #define y0 abc111qqz
21 #define y1 hust111qqz
22 #define yn hez111qqz
23 #define j1 cute111qqz
24 #define tm crazy111qqz
25 #define lr dying111qqz
26 using namespace std;
27 #define REP(i, n) for (int i=0;i<int(n);++i)  
28 typedef long long LL;
29 typedef unsigned long long ULL;
30 const int inf = 0x7fffffff;
31 const int N=1E6+7;
32 multiset<int>se;
33 multiset<int>::iterator it;
34 int main()
35 {
36     int n;
37     int cmd;
38     int x;
39     scanf("%d",&n);
40     for ( int i = 0 ; i < n;  i++)
41     {
42     scanf("%d",&cmd);
43     if (cmd==1)
44     {
45         scanf("%d",&x);
46         se.insert(x);
47     }
48     if (cmd==2&&!se.empty())
49     {
50         se.erase(se.begin());
51     }
52     if (cmd==3)
53     {
54         if (se.empty())
55         {
56         printf("0\n");
57         }
58         else
59         {
60         it = se.end();
61         it--;
62         printf("%d\n",*it);
63         }
64     }
65     }
66     return 0;
67 }
View Code

 

2015 多校 #5 1007 MZL's simple problem

标签:

原文地址:http://www.cnblogs.com/111qqz/p/4711615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!