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

int constexpr N = 300'010;
int n, a[N];
vector<int> C;

int main() {

    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];

    sort(&a[1], &a[n] + 1);
    for(int i = 1; i <= n; ++i) {
        if(i == 1 || a[i] != a[i - 1]) {
            C.push_back(1);
        } else ++C.back();
    }

    for(int k = 1; k <= n; ++k) {
        int ans = 0;
        vector<int> oth;

        for(int x : C) {
            if(x / k > 0) {
                ans += x / k * k;
                oth.push_back(x);
            }
        }
        C.swap(oth);

        cout << ans << " ";
    }
    cout << "\n";

    return 0;
}