堆 STL

https://blog.csdn.net/qq_41687938/article/details/119257046
 1 #include <bits/stdc++.h>
 2 #include <queue> 
 3 using namespace std;
 4 int n;
 5 int x;
 6 int op;
 7 int main ()
 8 {
 9     priority_queue<int,vector<int>,greater<int> > c;
10     cin>>n;
11     for(int i=1;i<=n;i++)
12     {
13         cin>>op;
14         if(op==1)
15         {
16             cin>>x;
17             c.push(x);
18         }
19         if(op==2)
20         {
21             if(!c.empty())
22             cout<<c.top()<<endl;
23         }
24         if(op==3)
25         c.pop();
26         
27     }
28     return 0;
29 }

 

posted @ 2023-07-08 11:22  一纸书歌  阅读(14)  评论(0)    收藏  举报