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

using namespace std;

int main(){
    unordered_map<int, int> counts;

    int n, tmp;
    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        scanf("%d", &tmp);
        counts[tmp]++;
    }

    std::vector<int> res(n + 1, 0);
    int per_person;

    for(auto & [key, value] : counts){
        for (int i = 1; i <= value; i++) {
            per_person = value / i;
            res[i] += per_person * i;
        }
    }
    for (int i = 1; i <= n; i++) {
        printf("%d ", res[i]);
    }

    return 0;
}