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
#include <iostream>
#include <set>

int main()
{
	int n = 0;

	std::cin >> n;

	int *nums = new int[n];

	// nums caounter array initial value is 0
	int *numsCounter = new int[500000]();
	int maxNumCounter = 0;

	for (int i = 0; i < n; i++)
	{
		std::cin >> nums[i];

		int num = nums[i];

		numsCounter[num]++;

		if (numsCounter[num] > maxNumCounter)
		{
			maxNumCounter = numsCounter[num];
		}
	}

	int maxNumCounterCount = 0;
	// set of numbers with the same max counter
	std::set<int> maxNumsCounterSet;

	for (int i = 0; i < n; i++)
	{
		// if set contains the number, then it is already counted
		if (numsCounter[nums[i]] == maxNumCounter)
		{
			maxNumCounterCount++;
			maxNumsCounterSet.insert(nums[i]);
		}
	}

	// amount of numbers in set
	int maxNumsCounterSetSize = maxNumsCounterSet.size();

	std::cout << maxNumCounterCount / maxNumsCounterSetSize << std::endl;

	return 0;
}