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
#include <cstdio>
#include <algorithm>

#define REP(a, n) for (int a = 0; a < (n); ++a)

using namespace std;

//////////////////////////

int N;
int ile[500001];

int main() {
    scanf("%d", &N);
    REP(a, N) {
        int i;
        scanf("%d", &i);
        ile[i-1]++;
    }
    sort(ile, ile+N);
    int wyn = 0;
    int g = N - 1;
    int l = 0;
    while (l<=g) {
        int c = 0;
        while (l < g && c+ile[l]<ile[g])
            c += ile[l++];
        if (l < g)
            ile[l] -= ile[g]-1-c;
        --g;
        ++wyn;
    }
    printf("%d\n", wyn);
}