We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 33363aa commit 1c1e503Copy full SHA for 1c1e503
21/2.cpp
@@ -0,0 +1,29 @@
1
+#include <bits/stdc++.h>
2
+
3
+using namespace std;
4
5
+void heapSort(vector<int>& arr) {
6
+ priority_queue<int> h;
7
+ // 모든 원소를 차례대로 힙에 삽입
8
+ for (int i = 0; i < arr.size(); i++) {
9
+ h.push(-arr[i]);
10
+ }
11
+ // 힙에 삽입된 모든 원소를 차례대로 꺼내어 출력
12
+ while (!h.empty()) {
13
+ printf("%d\n", -h.top());
14
+ h.pop();
15
16
+}
17
18
+int n;
19
+vector<int> arr;
20
21
+int main() {
22
+ cin >> n;
23
+ for (int i = 0; i < n; i++) {
24
+ int x;
25
+ scanf("%d", &x);
26
+ arr.push_back(x);
27
28
+ heapSort(arr);
29
0 commit comments