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

int main() {
	int count;
	std::cin >> count;
	std::vector<int> cities;
	cities.reserve(count);
	std::unordered_map<int, int> citiesMap;
	for (int i = 0; i < count; i++) {
		int tmp;
		std::cin >> tmp;
		citiesMap[tmp]++;
	}
	for (auto& entry : citiesMap) {
		cities.push_back(entry.second);
	}
	
	std::sort(cities.begin(), cities.end(), std::greater<int>{});
	std::vector<int> result(count + 1, 0);
	for (int i = 1; i <= count; i++) {
		int sum{0};
		for (int j = 0; j < cities.size(); j++) {
			int currentAmount = cities[j];
			int remainder = currentAmount % i;
			int toBeAdded = currentAmount - remainder;
			if (toBeAdded == 0) {
				break;
			}
			sum += toBeAdded;
		}
		result[i] = sum;
	}
	for (int i = 1; i <= count; i++) {
		std::cout << result[i] << (i < count ? " " : "");
	}
	std::cout << "\n";
	return 0;
}