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

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> m;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        m[x]++;
    }

    vector<int> ans(n,0);
    for (auto p : m) {
        int val = p.second;
        for (int i = 1; i <= val; i++) {
            ans[i-1] += i * (val / i);
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}