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

int main(){
    int n;
    cin>>n;
    vector<int> v(n+1, 0);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v[x] ++;
    }
    int res = 0;
    sort(v.begin(), v.end());
    int i = v.size()-1;
    int j = 0;
    while(j<i){
        int sum = 0;
        res++;
        while( j<i && sum+v[j] < v[i]){
            sum += v[j];
            v[j] = 0;
            j++;
        }
        int x = v[i] - sum - 1;
        v[j] -= x;
        i--;
    }
    if(v[i] > 0) res++;
    cout<<res<<'\n';

}