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

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL); //zgodnie z radą
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cityToStamps;

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

    vector<int> stampsCounts;
    for (auto& pair : cityToStamps) {
        stampsCounts.push_back(pair.second);
    }

    sort(stampsCounts.begin(), stampsCounts.end(), greater<int>());

    for (int k = 1; k <= n; ++k) {
        long long sum = 0;
        for (int count : stampsCounts) {
            sum += (count / k) * k;
        }
        if (sum == 0) { // Jeśli suma wynosi 0, wszystkie kolejne też będą 0
            while (k <= n) {
                cout << 0 << " ";
                ++k;
            }
            break;
        }
        cout << sum << " ";
    }

    return 0;
}