-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11286.cpp
More file actions
78 lines (50 loc) · 1.01 KB
/
11286.cpp
File metadata and controls
78 lines (50 loc) · 1.01 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// 11286.cpp
// algo
//
// Created by 박효정 on 2021/07/31.
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
struct qu{
int val;
int abs;
qu(int a,int b){
val=a;
abs=b;
}
bool operator <(const qu & b)const{
if(abs==b.abs){
return val>b.val;
}else{
return abs>b.abs;
}
}
};
int main(){
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
priority_queue<qu>pq;
int n;
cin>>n;
int a;
while(n--){
cin>>a;
if(a!=0){
pq.push(qu({a,abs(a)}));
}else{
if(pq.empty()){
cout<<0<<"\n";
}else{
cout<<pq.top().val<<"\n";
pq.pop();
}
}
}
return 0;
}