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
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * Patryk Kisielewski
 * 
 * Potyczki Algorytmiczne 2024
 * Zadanie: LID - Liderzy [B]
*/
#include <vector>
#include <utility>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;

    vector<int> v(n + 1, 0);

    int x;

    for (int i = 0; i < n; ++i) {
        cin >> x;
        v[x] += 1;
    }

    sort(v.begin(), v.end());

    auto start = upper_bound(v.begin(), v.end(), 0);

    int total = 0;
    int count = 0;

    auto it = v.end() - 1;
    while (true) {
        ++count;
        total += 2 * (*it) - 1;
        if (total >= n) {
            break;
        }
        if (it == start) {
            break;
        }
        --it;
    }

    cout << count << '\n';

    return 0;
}