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
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;

int stamps[300 * 1000 + 10];

int read_stamps(const int n)
{
   map<int, int> in2city;
   int tmp, tmpmapped, next = 1;
   for (int i=0; i<n; ++i) {
      scanf("%d", &tmp);
      tmpmapped = in2city[tmp];
      if (tmpmapped > 0)
         ++stamps[tmpmapped];
      else {
         in2city[tmp] = next;
         stamps[next] = 1;
         ++next;
      }
   }
   return next;
}

int main()
{
   int n, max_city;
   scanf("%d", &n);
max_city = read_stamps(n);
                                                                                                                                                                                                                                                     sort(&stamps[1], &stamps[max_city]);
   for (int p=1; p<=n; ++p) {
      int sum = 0;
      for (int i=max_city-1; i>0; --i) {
         if (stamps[i] < p)
            break;
         sum += (stamps[i] / p) * p;
      }
      printf("%d ", sum);
   }
   printf("\n");
}