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;

int n, mx, city;
vector <int> cities;
unordered_map <int, int> m;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        if(!m[x]){
            m[x] = ++city;
            cities.push_back(1);
        }
        else cities[m[x] - 1] += 1;
    }
    sort(cities.begin(), cities.end(), greater<int>());
    mx = *cities.begin();
    for(int k = 1; k <= n; ++k){
        if(k > mx){
            cout << 0 << ' ';
            continue;
        }
        int ans = 0;
        for(auto x : cities){
            if(k > x) break;
            ans += (x/k)*k;
        }
        cout << ans << ' ';
    }
}