-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11286.cpp
55 lines (52 loc) · 887 Bytes
/
11286.cpp
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
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <deque>
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
typedef struct var{
int num;
int abs;
} var;
struct cmp {
bool operator () (var t, var n) {
if (t.abs == n.abs) {
return t.num > n.num;
}
return t.abs > n.abs;
}
};
priority_queue <var, vector<var>, cmp> arr;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int a[20001] = { 0, };
int n, tmp;
cin >> n;
for (int k = 1; k <= n; k++) {
cin >> tmp;
if (tmp != 0) {
var tel;
tel.num = tmp;
tel.abs = abs(tmp);
arr.push(tel);
}
else {
if (arr.size() != 0) {
printf("%d\n", arr.top().num);
arr.pop();
}
else {
printf("0\n");
}
}
}
return 0;
}