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

using namespace std;

vector<int>inp;
int out[300002];

int main(){
  int n, a;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a;
    inp.push_back(a);
  }
  sort(inp.begin(), inp.end());
  inp.push_back(2134700000);
  int suma=1;
  for(int i=1; i<=n; i++){
    if(inp[i] != inp[i-1]){
      int j=1;
      while(suma/j){
        out[j]+=((suma/j)*j);
        j++;
      }
      suma=1;
    }
    else suma++;
  }
  for(int i=1; i<=n; i++) cout<<out[i]<<" ";
  return 0;
}