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
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  map<long long, long long> znaczki;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    long long city;

    scanf("%lld", &city);

    if (znaczki.contains(city)) {
      znaczki[city]++;
    }
    else {
      znaczki[city] = 1;
    }
  }

  vector<long long> counts;

  for (auto it = znaczki.begin(); it != znaczki.end(); ++it) {
    counts.push_back(it->second);
    // printf("%d %d\n", it->first, it->second);
  }

  sort(counts.begin(), counts.end(), greater<>());

  for (long long i = 1; i <= n; i++) {
    unsigned long long result = 0;

    for (long long j = 0; j < counts.size() && counts[j] >= i; j++) {
      result += counts[j] / i * i;
    }

    printf("%llu ", result);
  }

  return 0;
}