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
#include <stdio.h>
#include <unordered_map>
#include <vector>
#include <functional>

using namespace std;

int N;
unordered_map<int, int> U;
vector<int> V;
int main() {
    scanf("%d",&N);
    for (int i=0;i<N;++i) {
        int v;
        scanf("%d",&v);
        if (!U.contains(v)) {
            U[v] = 1;
        } else {
            U[v] = U[v] + 1;
        }
    }

    for (const auto& [key, value] : U)
        V.push_back(value);

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

    int last_start = 0;
    for (int i=1;i<=N;++i) {
        int sum = 0;
        for (int j=last_start;j<V.size();++j) {
            int dz = (int)(V[j]/i);
            sum += dz * i;
            if (dz == 0) {
                last_start = j;
            }
        }
        printf("%d ", sum);
    }

    return 0;
}