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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>

using namespace std;

#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define pb push_back
#define umii unordered_map<int, int>
#define mii map<int, int>

int tab[300008];
vpii wyniki;
mii miasta;
vi retard;
bool vis[300008];

void reindex (int idx, int n)
{
    for (int i=0; i<n; i++)
    {
        for (int j=idx; j<retard.size(); j++)
        {
            if (i <= retard[j] && retard[j] != 0)
            {
                tab[i+1] += retard[j];
                int temp = retard[j] % (i+1);
                tab[i+1]-=temp;
            }
            else if (n!=j)
            {
                idx=j;
            }
            else
            {
                continue;
            }
        }
    }
}

int main()
{
    speed;
    int n,nr,idx;
    cin>>n;
    int rikard=n;
    while (rikard--)
    {
        cin>>nr;
        wyniki.pb(make_pair(1,nr));
    }
    for (int i=0; i<n; i++)
    {
        miasta[wyniki[i].second]++;
    }
    for (auto it=miasta.begin(); it!=miasta.end(); it++)
    {
        retard.pb(it->second);
    }
    sort(retard.begin(), retard.end());
    for (int i=0; i<retard.size(); i++)
    {
        if (retard[i] != 0)
        {
            idx=i;
            goto g;
        }
    }
    g:
    reindex(idx,n);
    for (int i=0; i<n; i++)
    {
        cout<<tab[i+1]<<" ";
    }
    return 0;
}