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
#include <bits/stdc++.h>
#define pb push_back
#define inf 999999999
#define turbo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int res[300015];

int main()
{
    turbo;
    int n;
    cin >> n;
    map <int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        mp[x]++;
    }
    for (auto it : mp)
    {
        for (int i = 1; i <= it.second; i++)
        {
            res[i] += (it.second / i) * i;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << res[i] << " ";
    }
    return 0;
}