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
#include<bits/stdc++.h>
using namespace std;
const int N=500003;
vector <int> v(N);
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int x;
    for(int i=0; i<n; i++){
        cin>>x;
        v[x]++;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int idx1=0, idx2=n, zp, cnt=0;
    while(v[idx2]==0){
        idx2--;
    }
    while(idx1<=idx2){
        cnt++;
        zp=0;
        while((v[idx1]-1)>zp){
            v[idx2]--;
            if(v[idx2]==0){
                idx2--;
            }
            zp++;
        }
        idx1++;
    }
    cout<<cnt<<"\n";
    return 0;
}