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
#include <cstdio>
#include <map>

using namespace std;



int main()
{
	int n, w, m2;
	
	scanf("%d", &n);
	int* res = new int[n];
	map<int, int> z;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &w);
		res[i] = 0;
		z[w]++;
	}

	map<int, int>::iterator it = z.begin();
	

	while (it != z.end())
	{
		for (int i = 0; i < it->second; i++)
		{
			int j = it->second / (i + 1), k = i + 1;
			if (j == 0)
			{
				break;
			}
			res[i] += j * k;
		}
		it++;
	}

	for (int i = 0; i < n; i++)
	{
		printf("%d ", res[i]);
	}

	return 0;
}