#include <iostream>
#include <queue>
using namespace std;
int main() {
ios_base::sync_with_stdio;
cin.tie(0);
priority_queue<int> pq;
int T,number;
cin >> T;
while (T--) {
cin >> number;
if (number == 0) {
if (!pq.size()) {
cout << 0 << "\n";
}
else {
cout << pq.top() << "\n";
pq.pop();
}
}
else pq.push(number);
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 11365๋ฒ - !๋ฐ๋น ๊ธ์ผ (0) | 2021.10.27 |
---|---|
[๋ฐฑ์ค,c++] 11328๋ฒ - strfry (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 11286๋ฒ - ์ ๋๊ฐ ํ (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 11123๋ฒ - ์ ํ๋ง๋ฆฌ... ์ ๋๋ง๋ฆฌ... (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 1110๋ฒ - ๋ํ๊ธฐ ์ฌ์ดํด (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 1107๋ฒ - ๋ฆฌ๋ชจ์ปจ (0) | 2021.10.27 |
๋๊ธ