-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11286.cpp
More file actions
40 lines (32 loc) · 740 Bytes
/
11286.cpp
File metadata and controls
40 lines (32 loc) · 740 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 <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <queue>
using namespace std;
typedef long long int ll;
struct cmp {
bool operator() (ll x, ll y) {
if (abs(x) == abs(y)) return x > y;
return abs(x) > abs(y);
}
};
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
priority_queue<ll, vector<ll>, cmp> pq;
int n, chk; cin >> n;
while (n--) {
cin >> chk;
if (chk) pq.push(chk);
else {
if (pq.empty()) cout << "0\n";
else {
cout << pq.top() << "\n";
pq.pop();
}
}
}
return 0;
}