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
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, x;
	scanf("%d", &n);
	vector<int> a(n+1);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		a[x]++;
	}
	vector<int> b(n+1);
	for (int i = 1; i <= n; i++) b[a[i]]++;
	x = 0;
	for (int i = n, s = 0; s < n; i--) {
		while(s < n && b[i]--) {
			s += i+i-1;
			x++;
		}
	}
	printf("%d\n", x);
	return 0;
}