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

namespace {
	using std::ios_base, std::cin;
	using std::cout, std::multiset, std::vector;
	using msize_t = uint32_t;
};

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

	// Czytanie i przygotowywanie danych
	msize_t n, x;
	cin >> n;
	multiset<msize_t> elts;
	for (msize_t i = 0; i < n; ++i) {
		cin >> x;
		elts.insert(x);
	}
	vector<msize_t> cnts(1, 0);
	msize_t i_cnts = 0;
	auto it_elts = elts.begin();
	auto it_next = it_elts;
	for (msize_t i = 0; i < n; ++i) {
		++cnts[i_cnts];
		it_next = it_elts;
		++it_next;
		if (i + 1 < n && *it_elts != *it_next) {
			++i_cnts;
			cnts.push_back(0);
		}
		elts.erase(it_elts);
		it_elts = it_next;
	}

	// Obliczanie wyniku
	bool zero_sum = false;
	msize_t sum;
	for (msize_t k = 1; k <= n; ++k) {
		sum = 0;
		for (msize_t j = 0; !zero_sum && j < cnts.size(); ++j)
			sum += cnts[j] / k;
		if (sum == 0)
			zero_sum = true;
		cout << k * sum << ' ';
	}
	cout << '\n';
}