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
#include<unordered_set>
#include<cstdio>
#include<functional>

using namespace std;

int n;
unordered_multiset<int> C;
vector<int> P;

int main() {
	int a;
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%d", &a);
		C.insert(a);
	}
	for (auto it = C.begin(); it != C.end(); ) {
		auto count = C.count(*it);
		P.push_back(count);
		advance(it, count);
	}
	sort(P.begin(), P.end(), greater<int>());

	for (int i = 1; i <= n; i++) {
		int sum = 0;
		for (auto it = P.begin(); it != P.end(); it++) {
			sum += (*it / i) * i;
		}
		printf("%d ", sum);
		while (P.size() > 0 && P.back() <= i) {
			P.pop_back();
		}
	}
}