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

using namespace std;
typedef pair<int,int> pii;

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
	int n; cin >> n;
	
	vector<int> t(n);
	for(int i = 0; i < n; ++i) cin >> t[i];
	sort(t.begin(), t.end());
	
	vector<pii> v; int it = 1, dl = 1, w = t[0];
	while(it < n){
		if(t[it] == w) ++dl;
		else{
			v.emplace_back(dl, w); 
			dl = 1; w = t[it];
		}
		++it;
	}v.emplace_back(dl, w);

	sort(v.begin(), v.end()); int k, wynik = 0; it = 0;
	for(int i = v.size() - 1; ~i; --i){
		dl = v[i].first; k = dl - 1;
		while(k){
			if(it == i) break;
			if(v[it].first > k){
				v[it].first -= k; break;
			}
			else{k -= v[it].first; ++it;}
		} ++wynik;
		if(it == i) break;
	}
	
	cout << wynik << "\n";
	
	
	return 0;
}