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<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll inf=1e18;

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    ll n;cin>>n;
    map<ll,ll>cnt;
    vector<ll>vec(n);
    for(ll&i:vec)
    {
        cin>>i;
        cnt[i]++;
    }
    vector<ll>aa;
    for(auto[a,c]:cnt)aa.push_back(c);
    sort(begin(aa),end(aa),greater<>{});
    ll cn=0,sm=0;
    for(ll a:aa)
    {
        cn++;sm+=a*2-1;
        if(sm>=n)break;
    }
    cout<<cn;
}