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
#include <iostream>
#include <vector>
#include <map>

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

    int N;
    std::cin >> N;

    std::map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        int x;
        std::cin >> x;
        cnt[x]++;
    }

    std::vector<int> active;
    for(auto [x, c] : cnt) {
        active.push_back(c);
    }

    for(int k = 1; k <= N; k++) {
        int result = 0;
        std::vector<int> next;
        for(int c : active) {
            if(c >= k) {
                next.push_back(c);
                result += c - (c % k);
            }
        }
        active = next;
        std::cout << result << ' ';
    }
    std::cout << '\n';

    return 0;
}