2015 多校 #5 1007 MZL's simple problem

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 (N≤106),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: [email protected]
 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 }

2015 多校 #5 1007 MZL's simple problem

时间: 2024-08-02 00:18:16

2015 多校 #5 1007 MZL's simple problem的相关文章

HDU 5349(2015多校5)-MZL&#39;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&

hdu5348(2015多校5)--MZL&#39;s endless loop(搜索)

题目链接:点击打开链接 题目大意:给出n个点,m条无向边,现在要求将无向边变为有向边,要保证每个点的出度和入度的差不超过1 直接进行搜索,对每个点进行出度和入度的判断,如果出度大,就先进行反向的搜索(每搜索一条边u,v就认为这是一条v到u的有向边),反之,进行正向搜索(每搜到一条边u,v认为这是一条u到v的有向边),一直搜索到找不到边能继续为止. 注意: 1.已经使用过的边为了防止再次被遍历,可以修改head,head[u] = edge[i].next 2.注意自环,因为搜索是判断能不能继续向

hdu5351(2015多校5)--MZL&#39;s Border(打表,,找规律)

题目链接:点击打开链接 题目大意:给出b1 = 'b' , b2 = 'a' , bi = b(i-1)b(i-2),将i-1和i-2链接起来,记录一个串的s[1-i] 和s[n-i+1-n]相同的话 Border,当i为最长是为LBorder,现在给让求在bn这个串上的前m个字符组成的子串的LBorder 通过计算可以发现,b字符串的前缀都是相同的,所以只要求出m的LBorder就行,和n是无关的,打表找出规律,找出对应不同的m,LBorder的值,因为存在大数,用java写 dp[i]第i层

2015 多校 #5 1005 MZL&#39;s chemistry

MZL's chemistry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1306    Accepted Submission(s): 601 Problem Description MZL define F(X) as the first ionization energy of the chemical element X N

2015多校 #5 1002 MZL&#39;s xor

MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1509    Accepted Submission(s): 619 Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to

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