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
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

bool cmp(int a, int b)
{
  return a > b;
}

int main()
{
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  unordered_map<int, int> num_to_counters;

  for(int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    num_to_counters[x]++;
  }

  vector<int> counters;
  for(auto num_to_counter : num_to_counters)
  {
    counters.push_back(num_to_counter.second);
  }
  sort(counters.begin(), counters.end(), cmp);


  cout << n << " ";
  //int prev = n;

  for(int i = 2; i <= n; i++)
  {
    int cur = 0;
    for(auto k : counters)
    {
      cur += k / i;
      if(k / i == 0)
      {
        break;
      }
    }
    cout << cur * i << " ";
    //prev = cur;
  }
  cout << endl;

}