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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <bits/stdc++.h>

using namespace std;

#define ll long long

template<class T>
int ssize(T &c)
{
	return (int)c.size();
}

template<class T>
istream &operator>>(istream &is, vector<T> &vec)
{
	for (auto &v : vec)
		is >> v;

	return is;
}

template<class T>
auto operator<<(ostream &os, T &x)->decltype(x.end(), os);

template<class A, class B>
auto &operator<<(ostream &o, pair<A,B> &x)
{
	return o << "(" << x.first << " " << x.second << ")";
}

template<class T>
auto operator<<(ostream &os, T &x)->decltype(x.end(), os)
{
	os << "{";
	int i = 2;
	for(auto &e : x)
		os << (", ") + i << e, i = 0;

	return os << "}";
}

auto &operator<<(ostream &os, string &x)
{
	return os << x.c_str();
}

#ifdef DEBUG
#define LOG(x...) cerr << "["#x"]: ", [](auto... e){ ((cerr << e << "; "), ...) << "\n"; }(x)
#else
#define LOG(x...) 0
#endif

#define written_by return
#define efindus
#define in_2024 0

int main()
{
	cin.tie(NULL)->sync_with_stdio(false);

	int n;
	cin >> n;

	map<int, int> counts_map;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		counts_map[a]++;
	}

	vector<int> counts;
	counts.reserve(ssize(counts_map));
	for (auto &x : counts_map)
		counts.push_back(x.second);

	sort(counts.rbegin(), counts.rend());

	vector<int> res(n);
	int index = 0;
	for (int i = n; i > 0; i--) {
		if (i > counts[index])
			continue;

		while (index + 1 < ssize(counts) && i <= counts[index + 1])
			index++;

		auto &c = res[i - 1];
		for (int x = 0; x <= index; x++)
			c += (counts[x] / i) * i;
	}

	for (int i = 0; i < n; i++)
		cout << res[i] << " ";

	cout << "\n";

	written_by efindus in_2024;
}