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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> V;
int T[500003];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{

		int a;
		cin >> a;
		T[a] ++;
		/*
		int a; cin >> a;
		V.push_back(a);
		*/
	}
	for (int i = 1; i <= n; i ++) if (T[i] != 0) V.push_back(T[i]);
	sort(V.begin(), V.end(), greater<int>());

	int i = 0;
	for (; i < V.size(); i++)
	{
		int a = V[i];
		//cout << a << "\t";
		int sum = 0;
		while (i < V.size() - 1 && sum + V.back() < a)
		{
			sum += V.back();
			//cout << V.back() << ' ';
			V.pop_back();
		}
		if (i < V.size() - 1) {
			V.back() -= (a - 1 - sum);
			//cout << (a - 1 - sum) << ' ';
			sum = a - 1;
			if (V.back() == 0) V.pop_back();
		}
		//cout << '\n';
	}
	cout << i << '\n';
}