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
55
56
57
58
59
#include <bits/stdc++.h>

using std::cin, std::cout;
using std::string;
using std::array;
using std::vector;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
const char endl = '\n';

template<class num>
inline num ceildiv(num a, num b) { return (a + b - 1) / b; }

template<class num>
inline num modulo(num i, num n) { //return value >= 0
    const num k = i % n;
    return k < 0 ? k + n : k;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n; cin >> n;

    std::map<int, int> occurences; 

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

    vector<int> counts;

    for (auto [city, count] : occurences) {
        counts.push_back(count);
    }

    std::ranges::sort(counts, std::greater{});

    int right = n;
    for (int people = 1; people <= n; people++) {
        int sum = 0;
        for (int i = 0; i < right; i++) {
            if (counts[i] < people) {
                right--;
                break;
            }
            sum += (counts[i] / people) * people;
        }
        cout << sum << ' ';
    }

    cout << endl;
    return 0;
}