From f0de9815e58ed406ed5414ad445182b964aafdd7 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Wed, 27 May 2026 03:15:25 +0900 Subject: [PATCH] =?UTF-8?q?2910=20:=20=EB=B9=88=EB=8F=84=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week2/BOJ2910/BOJ2910_V1.cpp | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/week2/BOJ2910/BOJ2910_V1.cpp diff --git a/src/week2/BOJ2910/BOJ2910_V1.cpp b/src/week2/BOJ2910/BOJ2910_V1.cpp new file mode 100644 index 0000000..18943dd --- /dev/null +++ b/src/week2/BOJ2910/BOJ2910_V1.cpp @@ -0,0 +1,46 @@ +#include +using namespace std; +bool sorting_algorithm(tuple a, tuple b) { + if (get<1>(a) != get<1>(b)) { + return get<1>(a) > get<1>(b); + } + return get<2>(a) < get<2>(b); +} +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int N,C; + cin >> N >> C; + + //입력 숫자, 입력 숫자 개수, 입력 숫자의 입력순서 + map > m; + vector > ret; + + for (int i = 0; i < N; i++) { + int temp; + cin >> temp; + if (m.find(temp) != m.end()) { + get<1>(m[temp])++; + } else { + m[temp] = {temp, 1, i}; + } + } + + for (auto it : m) { + ret.push_back(it.second); + } + + sort(ret.begin(), ret.end(), sorting_algorithm); + + for (auto it : ret) { + for (int i=0; i(it); i++) { + cout << get<0>(it) << " "; + } + } + + + return 0; +} \ No newline at end of file