1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>

int main() {
    int n;
    std::cin >> n;
    std::unordered_map<int, int> counts;
    for(int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        counts[a]++;
    }
    std::vector<int> f(n + 1, 0);
    for(auto p : counts) {
        int c = p.second;
        for(int k = 1; k <= c; k++) {
            f[k] += (c / k) * k;
        }
    }
    for(int k = 1; k <= n; k++) {
        std::cout << f[k] << " ";
    }
    std::cout << std::endl;
}