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
# include <bits/stdc++.h>
# define For(i, l, r) for(int i = (l); i <= (r); i++)
# define Rep(i, n) For(i, 0, (n) - 1)
# define size(x) (ll)x.size()
# define MAXSZ 300005
# define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
ll n , m , k , q , t;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    vector vec(n , 0LL);
    unordered_map<ll , ll>kol;
    Rep (i , n) {
         cin >> vec[i];
         kol[vec[i]]++;
    }
    vector sum(n + 5 , 0LL);
    for (auto [el , cnt] : kol) {
          ll can = cnt , prev = 0 , x = 1;
          while (can > 0 && x <= n) {
              sum[x] += can - prev;
              ll l = x , r = n + 1;
              while (r - l != 1) {
                  ll mid = (l + r) / 2;
                  ll can_mid = cnt / mid;
                  if (can < can_mid)l = mid;
                  else r = mid;
              }
              x = r;
              prev = can;
              can = cnt / r;
          }
          sum[x] += -prev;
    }
    For (i , 1 , n) {
         sum[i] += sum[i - 1];
         cout << sum[i] * i << ' ';
    }
}
//odjgoadfhfoav hash1 i hash2 (hash1 * 1e9 + hash