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
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <map>

using namespace std;

int *pom;

void merge(int tab[], int left, int midd, int right) 
{
  int i, j;
  for(i = midd + 1; i>left; i--){
    pom[i-1] = tab[i-1];
    }

 
  for(j = midd; j<right; j++) 
    pom[right+midd-j] = tab[j+1];
  for(int k=left;k<=right;k++) 
    if(pom[j]>pom[i])
      tab[k] = pom[j--];
    else
      tab[k] = pom[i++];
}

void mergeSort(int tab[],int left, int right)
{
    if(right<=left) return; 

    int midd = (right+left)/2;
    mergeSort(tab, left, midd);
    mergeSort(tab, midd+1, right);
    merge(tab, left, midd, right);
}
 
int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    map<int, int> mp;

    int n, kapusta;
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>kapusta;
        mp[kapusta]++;
    }

    int ile_roznych = mp.size();
    pom = new int[ile_roznych];
    int sortowanie[ile_roznych];
    map<int, int>::iterator it = mp.begin();
    int tmp = 0;
    while (it != mp.end()) {
        sortowanie[tmp] = it->second;
        tmp++;
        ++it;
    }
    mergeSort(sortowanie, 0, ile_roznych - 1);

    cout<<n<<" ";

    int a, aktu_suma;
    for (int i=2; i<=n; i++) {
        aktu_suma = 0;
        for (int j=0; j<ile_roznych; j++) {
            a = sortowanie[j] / i;
            if (a == 0) {
                break;
            }
            a *= i;
            aktu_suma += a;
        }
        cout << aktu_suma << " ";
        if (aktu_suma == 0) {
            i++;
            while (i<=n) {
                cout<<"0 ";
                i++;
            }
        }
        //a = sortowanie[i-1] / i;
        //a *= i;
    }

    return 0;
}