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
#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<int> t(n);
  for(int& i : t)
    cin >> i;

  sort(t.begin(), t.end());
  t.push_back(-1);

  vector<int> result(n+1, 0);
  int last = -2;
  int cnt = 0;
  for(int x : t) {
    if(last != x) {
      for(int i=1;i<=cnt;i++)
        result[i] += i * (cnt / i);

      cnt = 0;
      last = x;
    }
    cnt++;
  }

  for(int i=1;i<=n;i++)
    cout << result[i] << " ";
  cout << "\n";

  return 0;
}