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
#include<bits/stdc++.h>

using std::cin, std::cout;
typedef std::pair<int,int> p;

std::vector<int> v;
const int MAXN = 5e5+1;
int cnt[MAXN];

int main() {
	cin.tie(0) -> sync_with_stdio(0);
	int n; cin >> n;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		cnt[x]++;
	}

	for(int i = 0; i < MAXN; ++i) if(cnt[i] != 0) v.push_back(cnt[i]);

	std::sort(v.begin(), v.end(), std::greater<int>());
	int res = 0;
	for(int i = 0; i < v.size(); ++i) {
		res++;
		int sum = 0;
		while(i != v.size() && sum + v.back() < v[i]) {
			sum += v.back();
			v.pop_back();
		}
	}
	cout << res;
}