洛谷P3378堆

传送门啦

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue> 
#define re register
using namespace std;

inline int read(){
	char ch = getchar();
	int f = 1 , x = 0;
	while(ch > '9' || ch < '0') {if(ch == '-') f = -1 ;ch = getchar();}
	while(ch >= '0' && ch <= '9' ) {x = (x << 1) + (x << 3) + ch - '0' ;ch = getchar();}
	return x * f;
}

priority_queue<int , vector <int> , greater <int> > q;

int n,flag,x;

int main(){
	n = read();
	while(n--){
		flag = read();
		if(flag == 1) {
			x = read(); 
			q.push(x);
		}
		else if(flag == 2) {
			printf("%d
",q.top());
		}
		else q.pop();
	}
	return 0;
}
原文地址:https://www.cnblogs.com/Stephen-F/p/9930400.html