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 <ranges>
#include <vector>
#include <iostream>
#include <numeric>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);

    int a, n;
    cin >> n;
    
    unordered_map<int, int> counter;
    for (int i = 0; i < n; i++) {
        cin >> a;
        counter[a]++;
    }

    vector<pair<int, int>> counts(counter.begin(), counter.end());

    sort(counts.begin(), counts.end(), [](const auto &a, const auto &b) {
        return a.second > b.second;
    });

    int count = 0;
    int sum = 0;
    for (const auto &pair: counts) {
        if (sum >= n) {
            break;
        }
        sum += pair.second + pair.second - 1;
        count += 1;
    }

    cout << count << endl;

    return 0;
}