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
#include<cstdio>
#include<unordered_map>
using namespace std;

const int N = 300'001;
int tab[N];
unordered_map<int,int>m;

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int amount;
        scanf("%d", &amount);
        m[amount]++;
    }
   
    while(!m.empty()){
        auto it = m.begin();
        int val = it -> second;
        m.erase(it -> first);
        for(int i  = 1; i <= val; i++){
            tab[i] += val / i;
        }
    }
    for(int i = 1; i <= n; i++) printf("%d ", tab[i] * i);
    return 0;
}