-
Notifications
You must be signed in to change notification settings - Fork 0
/
a218.cpp
42 lines (35 loc) · 858 Bytes
/
a218.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <ios>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstring>
bool comp(const std::pair<int, int>& p1, const std::pair<int, int>& p2)
{
if(p1.second > p2.second)
return true;
if(p1.second == p2.second && p1.first < p2.first)
return true;
return false;
}
int main()
{
int n;
int count_pool[10];
while(std::cin >> n){
memset(count_pool, 0, sizeof(count_pool));
for(int i=1; i<=n; ++i){
int temp;
std::cin >> temp;
count_pool[temp] += 1;
}
std::vector< std::pair<int, int> > result_pool;
for(int i=0; i!=10; ++i)
if(count_pool[i] != 0)
result_pool.push_back(std::make_pair(i, count_pool[i]));
std::sort(result_pool.begin(), result_pool.end(), comp);
for(size_t i=0; i!=result_pool.size(); ++i)
std::cout << result_pool[i].first << " ";
std::cout << "\n";
}
}