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
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;

    int a;
    vector<int> city;
    for(int i = 0; i<n; i++){
        cin>>a;
        city.push_back(a);
    }

    vector<int> count;
    count.assign(n+1, 0);
    sort(city.begin(), city.end());
    int cnt = 1;
    int ln = city[0];
    for(int i = 1; i<n; i++){
        if(ln != city[i]){
            for(int k = 1; k<=cnt; k++){
                count[cnt/k]++;
            }
            ln = city[i];
            cnt = 0;
        }
        cnt++;
    }
    for(int k = 1; k<=cnt; k++){
        count[cnt/k]++;
    }

    int tmp = 0;
    for(int i = n; i>=0; i--){
        tmp += count[i];
        count[i] = tmp;
    }

    for(int i = 0; i<n; i++){
        cout<<count[i+1]*(i+1)<<" ";
    }

    return 0;
}