-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1927_11279.cpp
More file actions
53 lines (50 loc) · 1.04 KB
/
1927_11279.cpp
File metadata and controls
53 lines (50 loc) · 1.04 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
#define FastIO\
ios_base::sync_with_stdio(false);\
cin.tie(NULL);\
cout.tie(NULL);
using namespace std;
// int main(){
// FastIO;
// int n;
// cin>>n;
// priority_queue<int, vector<int>, greater<int>> num;
// for(int i=0; i<n; i++){
// int temp;
// cin>>temp;
// if(temp==0){
// if(num.empty()){
// cout<<0<<"\n";
// }
// else{
// cout<<num.top()<<"\n";
// num.pop();
// }
// }
// else if(temp>0){
// num.push(temp);
// }
// }
// }
int main(){
FastIO;
int n;
cin>>n;
priority_queue<int> num;
for(int i=0; i<n; i++){
int temp;
cin>>temp;
if(temp==0){
if(num.empty()){
cout<<0<<"\n";
}
else{
cout<<num.top()<<"\n";
num.pop();
}
}
else if(temp>0){
num.push(temp);
}
}
}