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

using namespace std;

const int N = 5e5 + 7;
int ile[N];

int main() {
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        ile[x]++;
    }

    vector<int> v;
    for (int i = 1; i <= n; i++) {
        if (ile[i] != 0) {
            v.push_back(ile[i]);
        }
    }

    sort(v.begin(), v.end(), [](const int a, const int b){return a > b;});

    int wyn = 0;
    for (auto it : v) {
        wyn++;
        n -= it + it - 1;
        if (n <= 0)
            break;
    }
    cout << wyn << endl;
    return 0;
}