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

using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> d(n,0), c(n,0);
    for(int i =0;i<n;++i) cin>>d[i];
    for(const auto& dd:d) ++c[dd-1];
    sort(c.begin(), c.end(), greater<int>());

    int i=0, sum =0;
    while( sum < n)
    {
        sum+=(2*c[i]-1);
        ++i;
    }
    cout<<i;
    return 0;
}