-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11652.cpp
More file actions
29 lines (26 loc) · 541 Bytes
/
11652.cpp
File metadata and controls
29 lines (26 loc) · 541 Bytes
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
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
int N; cin >>N;
unordered_map<ll, int> m;
while (N--) {
ll a; cin >> a;
if (m.find(a) == m.end()) m[a] = 0;
m[a]++;
}
ll count = 0;
ll result = 0;
for (auto [a, n_count] : m) {
if (count < n_count) count = n_count, result = a;
if (count == n_count) result = min(result, a);
}
cout << result;
return 0;
}