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

int main() {
    int n;
    scanf(" %d", &n);
    
    map<int, int> counts;
    for (int i = 0; i < n; i++) {
        int a;
        scanf(" %d", &a);
        counts[a]++;
    }
    
    map<int, int> order;
    for (auto [_, v] : counts) {
        order[v]++;
    }

    for (int i = 1; i <= n; i++) {
        long long res = 0;

        for (auto it = order.begin(); it != order.end();) {
            if (i > it->first) {
                auto toErase = it;
                it++;
                order.erase(toErase);
            } else {
                res += (it->first/i) * it->second;
                it++;
            }
        }

        printf("%lld ", res*i);
    }
    puts("");
}