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
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>

using namespace std;

int main() {
    int *tab;
    int n;
    
    map<int, int> m;

    cin >> n;
    tab = new int[n+1];
    memset(tab, 0, sizeof(int)*(n+1));
    vector<int> heights;

    for(int i=0; i<n; i++) {
        int a;
        cin >> a;
        m[a]++;
    }

    for(const auto& pair : m) {
        heights.push_back(pair.second);
    }

    sort(heights.begin(), heights.end());

    int useless = 0;

    for(int i=1; i<=n; i++) {
        int tmp = 0;
        while(useless != heights.size() && i > heights[useless]) {
            useless++;
        }

        for(int j = useless; j<heights.size(); j++) {
            tmp += (heights[j] / i) * i;
        }

        cout << tmp << " ";
    }

    cout << endl;

    return 0;
}