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

int n;
std::unordered_map<int, int> counts;

void input() {
    std::cin >> n;
    int x;
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        counts[x]++;
    }
}

void solve() {
    std::vector<int> values;
    for (auto e : counts) {
        values.push_back(e.second);
    }

    std::sort(values.begin(), values.end());

    std::vector<int> results(n + 1);
    for (int v : values) {
        for (int i = 1; i <= v; i++) {
            results[i] += (v / i) * i;
        }
    }

    for (int k = 1; k <= n; k++) {

        std::cout << results[k] << " ";
    }
    std::cout << "\n";
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    input();
    solve();

    return 0;
}