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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,k=1;
    cin >> n;
    unordered_map<ll, ll> m;
    vector <ll> v(n+1,0);
    for(ll i=0;i<n;i++) {
        ll x;
        cin >> x;
        if(m[x]==0) {
            m[x]=k;
            k++;
        }
        v[m[x]]++;
    }
    vector <ll> res(n+1,0);
    for(ll i=0;i<=n;i++) {
        for(ll j=1;j<=v[i];j++) {
            res[j]+=(v[i]/j)*j;
        }
    }
    for(ll i=1;i<=n;i++) {
        cout<<res[i]<<" ";
    }
    return 0;
}