P3378 【模板】堆
P3378 【模板】堆
#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int> >q;//小根堆 int n; int op; int x; int main(){ scanf("%d",&n); while(n--){ scanf("%d",&op); if(op==1){ scanf("%d",&x); q.push(x); } else if(op==2){ printf("%d\n",q.top()); } else { q.pop(); } } return 0; }