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

static bool cmp(int a, int b)
{
    return b < a;
}

int main(void)
{
    int n;
    std::unordered_map<int, int> m;
    std::vector<int> v;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        m[a]++;
    }

    for (auto i : m)
        v.push_back(i.second);

    std::sort(v.begin(), v.end(), cmp);

    printf("%d", n);

    for (int k = 2; k <=n ; k++) {
        int s = 0;

        for (auto i : v) {
            if (i < k)
                break;

            s += i / k;
        }

        printf(" %d", s * k);
    }

    printf("\n");
    return 0;
}