标签:
6 1 2 1 3 3 1 3 1 4 3
3 4
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<string> #include<math.h> #include<queue> #include<stack> #include<map> #define INF 0x3f3f3f3f #define eps 1e-6 using namespace std; priority_queue<int, vector<int>, greater<int> > q;///从小到大排列 int n; int main() { while(scanf("%d",&n)!=EOF) { while(!q.empty()) { q.pop(); } int x,y; int flag = 0; int maxx; for(int i=0;i<n;i++) { scanf("%d",&x); if(x == 1) { scanf("%d",&y); if(flag == 0) { flag = 1; maxx = y; } if(maxx < y) { maxx = y; } q.push(y); } else if(x == 2) { if(q.size() > 0) { int tt = q.top(); while(!q.empty() && q.top() == tt) { q.pop(); } } if(q.size() <= 0) { flag = 0; } } else { if(q.size() > 0) { printf("%d\n",maxx); } else { printf("0\n"); } } } } return 0; }
版权声明:本文为博主原创文章,如有特殊需要请与博主联系 QQ : 793977586。
HDU 5349 MZL's simple problem(优先队列)
标签:
原文地址:http://blog.csdn.net/yeguxin/article/details/47297537