-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11279.cpp
More file actions
41 lines (38 loc) · 684 Bytes
/
11279.cpp
File metadata and controls
41 lines (38 loc) · 684 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
41
//C++ STL library using priority_queue (greater, less)
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <functional>
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
priority_queue<int, vector<int>, less<int> > a;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
if (tmp == 0) {
if (a.size()) {
printf("%d\n", a.top());
a.pop();
}
else {
printf("0\n");
}
}
else {
a.push(tmp);
}
}
return 0;
}