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

using namespace std;

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

    unordered_map<int, int> m;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> c;
    for (auto &[k, v] : m) c.push_back(v);
    sort(c.begin(), c.end());

    for (int k = 1; k <= n; ++k) {
        if (k > 1) cout << " ";
        // at most floor(n / k) numbers >= k.
        int ans = 0;
        for (int i = c.size() - 1; i >= 0 && c[i] >= k; --i) {
            ans += c[i] / k * k;
        }
        cout << ans;
    }
    cout << endl;
}