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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <vector>
#include <map>

std::vector<int> solve(int n, std::vector<int> &v)
{
    std::map<int, int> count;
    for (int stamp : v)
    {
        count[stamp]++;
    }

    std::map<int, int> freq;
    for (auto &pair : count)
    {
        freq[pair.second]++;
    }

    std::vector<int> ret(n, 0);

    int k = 1;
    for (; k <= n; ++k)
    {
        long long distributed = 0;
        for (auto &pair : freq)
        {
            int r = pair.first / k;
            if (r > 0)
            {
                distributed += static_cast<long long>(r) * k * pair.second;
            }
        }
        ret[k - 1] = distributed;
        if (distributed == 0)
        {
            break;
        }
    }

    return ret;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> v[i];
    }

    std::vector<int> res = solve(n, v);
    for (int i = 0; i < n; i++)
    {
        std::cout << res[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}