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
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;

const size_t maxn = 300'000;
map<int, int> m;
array<int, maxn + 1> a;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int n;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        if (m.find(tmp) != m.end()) {
            m[tmp]++;
        } else {
            m[tmp] = 1;
        }
    }

    int j = 0;
    for (auto i = m.begin(); i != m.end(); i++, j++) {
        a[j] = i->second;
    }
    
    int rozne = j;
    sort(a.begin(), a.begin() + j, greater<int>());
    int maxr = a[0];
    int dolny_limit = rozne;

    for (int i = 1; i <= n; i++) {
        if (i > maxr) {
            cout << "0 ";
            continue;
        }

        int suma = 0;
        for (int j = 0; j <= dolny_limit; j++) {
            if (a[j] / i == 0) {
                dolny_limit = j;
                break;
            }
            suma += a[j] / i;
        }

        cout << suma * i << " ";
    }

    cout << "\n";
	return 0;
}