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

int main()
{
	int N;
	scanf("%d", &N);

	std::vector<int> values;
	values.resize(N);
	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &values[i]);
	}

	std::sort(values.begin(), values.end());

	std::vector<int> counts;

	int ref = values[0];
	int cnt = 0;
	int i = 0;
	while(i < N)
	{
		while (i < N && values[i] == ref) { 
			++i; ++cnt; 
		}
		counts.push_back(cnt);
		if (i < N)
		{
			ref = values[i];
			cnt = 0;
		}
	}
	std::sort(counts.begin(), counts.end(), std::greater<int>());
	bool finished = false;
	printf("%d ", N);
	for (int i = 2; i <= N; ++i)
	{
		int res = 0;
		if (!finished) {
			for (int c : counts)
			{
				int groups = c / i;
				res += groups * i;
				if (groups == 0) break;
			}
		}
		if (res == 0) finished = true;
		printf("%d ", res);
	}
	puts("");
	return 0;
}