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
#include <cstdio>
#include <cstdlib>

int desc(const void *a, const void *b)
{
  return *(int *)b - *(int *)a;
}

int a[300000], p[300000];

int main()
{
  int n, m=0, b=0, r, s;
  scanf("%i", &n);
  for (int i = 0; i<n; i++) scanf("%i", &a[i]);
  qsort(a, n, sizeof(*a), desc);
  for (int i = 0; i<n; i++)
  {
    if (a[i] != b) b = a[i], m++;
    p[m-1]++;
  }
  qsort(p, m, sizeof(*p), desc);
  for (int i = 0; i<n; i++)
  {
    s = 0;
    for (int j = 0; j<m; j++)
    {
      r = p[j]-p[j]%(i+1);
      if (r == 0) break;
      s += r;
    }
    printf("%i%c", s, " \n"[i==n-1]);
  }
  return 0;
}