1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>

using namespace std;

int main(const int argc, char const * const argv[]) {
    uint32_t n;
    cin>>n;
    vector<uint32_t> count(n, 0);
    for(uint32_t i = 0; i < n; ++i) {
        uint32_t m;
        cin>>m;
        ++count[m - 1];
    }
    sort(count.begin(), count.end(), greater<>());
    uint32_t used = 0;
    uint32_t p = 0;
    uint32_t ans = 0;
    while(used < n) {
        used += count[p++] * 2 - 1;
        ++ans;
    }
    cout<<ans;
    return 0;
}