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
#include <bits/stdc++.h>

using namespace std;
vector<int>v;
set<int>s;
map<int, int>tab;
int maxi = -999999;
int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x;
        cin >> x;
        tab[x]++;
        s.insert(x);
    }
    for(auto i : s){
        v.push_back(tab[i]);
        maxi = max(tab[i], maxi);
    }
    for(int i = 1; i <= maxi; ++i){
        long long res = 0;
        for(auto j : v){
            int x = j/i;
            x*=i;
            res+=x;
        }
        cout << res << " ";
    }
    for(int i = maxi+1; i <= n; ++i){
        cout << 0 << " ";
    }
}