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
#include<iostream>
#include<algorithm>
using namespace std;
const int ILE = 500000;
int kub[ILE + 1], rozne = 0;
int oblicz(int n){
	int wynik = 0, i = 0, j = n-1, suma = 0;
	while(i <= j){
		if(kub[i] > suma + kub [j]){
			 suma+= kub[j];
			 j--;
		}
		else{ 
			suma = 0; 
			wynik++;
			i++; }
	}
	return wynik;			
}
int main(){
	int n, x;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x;
		if(kub[x] == 0) rozne++;
		kub[x]++;
	}
	sort(kub, kub + ILE, greater<int>());
	cout << oblicz(rozne);
}