Priority Queue Aizu - ALDS1_9_C

https://vjudge.net/problem/Aizu-ALDS1_9_C

 1 #include<cstdio>
 2 #include<queue>
 3 using namespace std;
 4 int main()
 5 {
 6     char com[20];
 7     priority_queue<int >PQ;
 8     while(1)
 9     {
10         scanf("%s",com);
11         if(com[0]=='i')
12         {
13             int key;
14             scanf("%d",&key);
15             PQ.push(key);
16         }
17         else if(com[1]=='x')
18         {
19             printf("%d\n",PQ.top());
20             PQ.pop();
21         }
22         else if(com[0]=='e')
23         {
24             break;
25         }
26     }
27     return 0;
28 }

 

posted @ 2020-12-08 20:17  BlackSnow  阅读(70)  评论(0)    收藏  举报