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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define pb push_back
const int M = 500007;
int tab[M];
bool comp(int a, int b)
{
	return a > b;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;

	for (int i = 0; i < n; i++)
	{
		int a; cin >> a; tab[a]++;
	}
	vector<int>v;
	for (int i = 0; i < M; i++)
	{
		if (tab[i] > 0){
			v.pb(tab[i]);
		}
	}
	sort(v.begin(), v.end(),comp);
	int sum = 0;
	int i = 0, j = v.size() - 1;
	while (i<j)
	{
		int x = v[i]; 
		int su = 0;
		sum++;
		while (x-1!= su)
		{
			if (su +v[j]  < x) {
				su += v[j];
				j--;
			}
			else
			{
				v[j] -= x - su - 1;
				su = x - 1;
			}
		}
		i++;
		
	}
	if (i == j)sum++;
	cout <<sum;
}