Skip to content

Commit 1d8a482

Browse files
committed
Update 2910.cpp
1 parent 09cb4d5 commit 1d8a482

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

0x0F/solutions/2910.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : jihwan0123
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/0fd334ddb06d417689cd6c944d5a0585
44
#include <bits/stdc++.h>
55
using namespace std;
66

7-
int main(void){
7+
#define X first
8+
#define Y second
9+
10+
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
11+
return a.X > b.X;
12+
}
13+
14+
int main(void) {
815
ios::sync_with_stdio(0);
916
cin.tie(0);
10-
17+
int n, c;
18+
cin >> n >> c;
19+
vector<pair<int, int>> arr; // pair : {cnt, num}
20+
for (int i = 0; i < n; i++) {
21+
int x;
22+
cin >> x;
23+
bool chk = false;
24+
for (auto &a : arr) {
25+
if (a.Y == x) {
26+
chk = true;
27+
a.X++;
28+
break;
29+
}
30+
}
31+
if (!chk) arr.push_back({1, x});
32+
}
33+
stable_sort(arr.begin(), arr.end(), cmp);
34+
35+
for (auto b : arr)
36+
while (b.X--) cout << b.Y << ' ';
1137
}

0 commit comments

Comments
 (0)