说的很好的三种做法:
点击打开链接
#include <stdio.h>
#include <queue>
#define min -1000000000
using namespace std;
int main()
{
int n, op, max, x;
priority_queue<int> q;
max = min;
while(scanf("%d", &n) != EOF)
{
while(n--)
{
scanf("%d", &op);
if(op == 1)
{
scanf("%d", &x);
q.push(x);
max = max>x?max:x;
}
else if(op == 2)
{
if(q.empty())
continue;
else
q.pop();
if(q.empty())
max = min;
}
else if(op == 3)
{
if(q.empty()) printf("0\n");
else printf("%d\n", max);
}
}
}
}