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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

constexpr uint32_t MAX_SIZE=300000;

struct stickers
{
	uint32_t num = 0;
	std::map<uint32_t,uint32_t> sts;
};

void load(std::istream& in, stickers& s)
{
	in >> s.num;
	for (int i =0; i < s.num; ++i)
	{
		uint32_t value = 0;
		in >> value;
		s.sts[value] ++;
	}
}

void print_map(std::ostream& out, stickers &s)
{
	out << "num: " << s.num << "\n";
	if (s.num < 10)
	{
		for (auto it = s.sts.begin(); it != s.sts.end(); it++)
		{
			out << "sts[" << it->first << "] = " << it->second << "\n";
		}
	}
}

void print_vect(std::ostream& out, std::vector<std::pair<uint32_t, uint32_t>> const &v)
{
	if (v.size() > 10)
	{
		return;
	}
	uint32_t i = 0;
	for (auto it = v.begin(); it != v.end(); it++)
	{
		out << "vect[" << i <<"] = " << it->first << ":" << it->second << "\n"; 
		i++;
	}
}

bool cmp(std::pair<uint32_t, uint32_t> &lhs, std::pair<uint32_t, uint32_t> &rhs)
{
	return lhs.second > rhs.second;
}

void sort_sts(std::map<uint32_t, uint32_t> &m, std::vector<std::pair<uint32_t,uint32_t>> &v)
{
	v.reserve(m.size());
	for (auto it = m.begin(); it != m.end(); it++)
	{
		v.push_back(*it);
	}
	sort(v.begin(), v.end(), cmp);
}

uint32_t given_stickers(std::vector<std::pair<uint32_t, uint32_t>> &v,
		uint32_t num)
{
	uint32_t given = 0;
	for (auto it = v.begin(); it != v.end(); it++)
	{
		auto stickers = it->second;
		auto allowed = stickers - (stickers % num);
		given += allowed;
		if (allowed == 0) 
		{
			return given;
		}
	}
	return given;
}

void prog_main(std::istream& in, std::ostream& out)
{
	stickers s;
	load(in, s);
	std::vector<std::pair<uint32_t, uint32_t>> v;
	sort_sts(s.sts, v);
	uint32_t i = 0;
	out << s.num;
	for (i = 2; i <= s.num; i++)
	{
		auto given_for = given_stickers(v, i);
		out << " " << given_for;
		if (given_for == 0)
		{
			break;
		}
	}
	for (uint32_t j = i+1; j <= s.num; j++)
	{
		out << " 0";
	}
	out << std::endl;
	//print_vect(std::cerr, v);
}



#ifndef TEST
int main(int argc, char* argv[])
{
	prog_main(std::cin, std::cout);
	return 0;
}
#endif