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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 300'003;
vector<int> v, amount;

int main(){
    int cnt, sum, last, n, a, firstNotZero = 0, now;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d", &a);
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    cnt = 1;
    last = v[0];
    for(int i = 1 ; i < n ; i++){
        if(v[i] != v[i - 1]){
            amount.push_back(cnt);
            cnt = 0;
        }
        cnt++;
    }
    amount.push_back(cnt);
    sort(amount.begin(), amount.end());
    for(int i = 1 ; i <= n ; i++){
        sum = 0;
        for(int j = firstNotZero ; j < amount.size() ; j++){
            now = amount[j] / i;
            if(!now) firstNotZero++;
            sum += now;
        }
        printf("%d ", i * sum);
    }
    printf("\n");
}