From 6ec448368c56c40ccab901308aa3fb0905e4d062 Mon Sep 17 00:00:00 2001 From: janghyoseog Date: Thu, 13 Jun 2019 20:43:19 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=20=EC=A0=95=EB=A0=AC=ED=95=98?= =?UTF-8?q?=EA=B8=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190613/hyodol/10989.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 190613/hyodol/10989.cpp diff --git a/190613/hyodol/10989.cpp b/190613/hyodol/10989.cpp new file mode 100644 index 0000000..7fac9ee --- /dev/null +++ b/190613/hyodol/10989.cpp @@ -0,0 +1,29 @@ +// BOJ 10989 - 수 정렬하기 3 +// Counting Sort +#include +#include +#include +using namespace std; +const int MAX = 10000; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); + + int n; + cin >> n; + + vector count(MAX+1); + for (int i = 0; i < n; i++) { + int num; + cin >> num; + count[num]++; + } + + for (int num = 0; num <= MAX; num++) { + if (count[num] == 0) continue; + while (count[num]--) cout << num << '\n'; + } + + return 0; +}