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
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> liczby(n);
    for(int i = 0; i < n; i++)
    {
        cin >> liczby[i];
    }
    sort(liczby.begin(), liczby.end());
    vector<int> amount;
    int counter = 1;
    for(int i = 0; i < n; i++)
    {
        if(i > 0)
        {
            if(liczby[i] != liczby[i - 1])
            {
                amount.push_back(counter);
                counter = 1;
            }
            else
            {
                counter++;
            }
        }
    }

    amount.push_back(counter);
    counter = 1;
    sort(amount.begin(), amount.end());
    vector<int> amount_label;
    vector<int> amount_count;
    for(int i = 0; i < amount.size(); i++)
    {
        if(i > 0)
        {
            if(amount[i] != amount[i - 1])
            {
                amount_count.push_back(counter);
                amount_label.push_back(amount[i - 1]);
                counter = 1;
            }
            else
            {
                counter++;
            }
        }
    }
    amount_label.push_back(amount[amount.size() - 1]);
    amount_count.push_back(counter);
    for(int i = 0; i < n; i++)
    {
        int result = 0;
        int j = amount_count.size() - 1;
        while(j >= 0 && amount_label[j] >= i + 1)
        {
            result += amount_count[j]*(floor(amount_label[j]/(i + 1)));
            j--;
        }
        cout << result * (i + 1) << " ";
    }
}