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
#include <algorithm>
#include <iostream>

int main() {

    int n;
    std::cin >> n;

    int x = 0;

    std::pair<int, int> zlicz[n+1];

    for (int i = 1; i <= n; i++) {
        zlicz[i].first = 0;
        zlicz[i].second = i;
    }

    for (int i = 0; i < n; i++) {
        std::cin >> x;
        zlicz[x].first++;
    }

    std::sort(zlicz, zlicz + n + 1);

    x = 0;
    for (int i = n; i > 0; i--) {
        n = n - 2*zlicz[i].first + 1;
        x++;
        if (n <= 0) {
            break;
        }
    }
    std::cout << x;
    return 0;
}