-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11279.cpp
More file actions
39 lines (35 loc) · 746 Bytes
/
Copy path11279.cpp
File metadata and controls
39 lines (35 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/****************
그냥 우선순위큐 문제
그다지 어렵지 않다. 그냥 priority queue를 알고만 있으면 됨.
****************/
#include <iostream>
#include <queue>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int num;
cin>>num;
priority_queue<int> pq; //우선순위 큐의 생성
for(int i=0;i<num;i++)
{
int tmp;
cin>>tmp;
if(tmp>0)
pq.push(tmp);
else if(tmp==0)
{
if(!pq.empty())
{
cout<<pq.top()<<"\n";
pq.pop();
}
else
{
cout<<0<<"\n";
}
}
}
}