-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11286.cpp
More file actions
40 lines (34 loc) · 751 Bytes
/
Copy path11286.cpp
File metadata and controls
40 lines (34 loc) · 751 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
40
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int ans(int a){
if(a<0) return -a;
return a;
}
auto cmp=[](int left,int right){
if(ans(left)!=ans(right)) return ans(left)>ans(right);
else return left>right;
};
priority_queue<int,vector<int>, decltype(cmp)> pq(cmp);
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tmp=0,testcase=0;
cin>>testcase;
while(testcase--){
cin>>tmp;
if(tmp==0){
if(pq.size()==0) cout<<"0"<<'\n';
else{
int tmp2=pq.top();
pq.pop();
cout<<tmp2<<'\n';
}
}
else pq.push(tmp);
}
return 0;
}