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
#include<bits/stdc++.h>

using namespace std;

int cnt[500010];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    int tmp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        cnt[tmp]++;
    }
    sort(cnt, cnt + n + 1, greater<int>());
    int sum = 0;
    int ans = 0;
    int ptr = 0;
    while(sum < n){
        // cout << sum << endl;
        ans++;
        sum += cnt[ptr] + cnt[ptr] - 1;
        ptr++;
    }
    cout << ans << "\n";
    return 0;
}