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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAXN = 5e5 + 7;
int a[MAXN];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    sort(a + 1, a + n + 1);
    vector<int> groups;
    int i = 1;
    while(i <= n){
        int akt = 0;
        int ele = a[i];
        while(i <= n && a[i] == ele){
            i++;
            akt++;
        }
        
        groups.push_back(akt);
    }
    
    sort(groups.begin(), groups.end());
    
    int l = 0;
    int p = (int)groups.size() - 1;
    int ans = 0;
    while(l <= p){
        if(l == p){
            ans++;
            l = p + 1;
            break;
        }
        ans++;
        while(l < p && groups[l] < groups[p]){
            groups[p] -= groups[l];
            l++;
        }
        
        if(l < p){
            groups[l] -= (groups[p] - 1);
        }
        p--;
    }
    
    cout << ans << '\n';
    
    return 0;
}