From 7510e570c923a66767f8e8a2fd61ede278e19249 Mon Sep 17 00:00:00 2001 From: Minsung_Kang Date: Thu, 28 Mar 2024 20:26:59 +0900 Subject: [PATCH] =?UTF-8?q?2024-03-28=20=EC=B5=9C=EB=8C=80=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rivkms/README.md | 4 +++- rivkms/queue/11279.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 rivkms/queue/11279.cpp diff --git a/rivkms/README.md b/rivkms/README.md index 1b0ecbc..c2bc680 100644 --- a/rivkms/README.md +++ b/rivkms/README.md @@ -9,4 +9,6 @@ | 5차시 | 2024.02.24 | Backtracking | [입대](https://www.acmicpc.net/problem/31413) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/18) | | 6차시 | 2024.02.27 | BFS | [토마토](https://www.acmicpc.net/problem/7576) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/20) | | 7차시 | 2024.03.01 | DP | [연속합](https://www.acmicpc.net/problem/1912) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/25) | -| 8차시 | 2024.03.01 | Greedy | [회의실 배정](https://www.acmicpc.net/problem/1931) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/28) | \ No newline at end of file +| 8차시 | 2024.03.01 | Greedy | [회의실 배정](https://www.acmicpc.net/problem/1931) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/28) | +| 9차시 | 2024.03.22 | two-pointer | [두 수의 합](https://www.acmicpc.net/problem/3273) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/38) | +| 10차시 | 2024.03.28 | queue | [최대힙](https://www.acmicpc.net/problem/11279) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/38) | \ No newline at end of file diff --git a/rivkms/queue/11279.cpp b/rivkms/queue/11279.cpp new file mode 100644 index 0000000..3b1eae7 --- /dev/null +++ b/rivkms/queue/11279.cpp @@ -0,0 +1,34 @@ +#include +#include + +using namespace std; + + + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, tmp; + cin >> n; + + priority_queue q; + vector printq; + for(int i = 0; i < n; i++){ + cin >> tmp; + if(tmp == 0){ + if(q.empty()){ + cout << 0 << "\n"; + } + else{ + cout << q.top() << "\n"; + q.pop(); + } + } + else{ + q.push(tmp); + } + } + return 0; +} \ No newline at end of file