#include<iostream>
#include <vector>
#include <map>
#include<algorithm>
using namespace std;
map<int,int> wyst;
vector<int> wiel;
bool testl(const vector<int> &wiel, int licz) {
	vector<int> wm;
	int ind, fv;
	ind = 0;
	for (auto i: wiel) {
		if (ind >= licz)
			wm.push_back(i);
		ind++;
	}
	ind = 0;
	for (int lid = 0; lid < licz; lid++) {
		fv = wiel[lid];
		while (ind < wm.size()) {
			if (wm[ind] < fv) {
				fv -= wm[ind];
				ind++;
			} else {
				wm[ind] -= (fv - 1);
				break;
			}
		};
	}
	return wm.size() == ind;
}
int main() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int liczba, el;
	cin >> liczba;
	
    for (int i=0; i < liczba; i++) {
		cin >> el;
        wyst[el]+=1;
	}
    for (auto i: wyst)
		wiel.push_back(i.second);
	sort(wiel.begin(), wiel.end(), greater<int>()); 
	int lewy, prawy, sr;
	lewy = 1;
	prawy = liczba;
	while (lewy < prawy) {
		sr = (lewy + prawy)/2;
		// cout << lewy << " " << sr << " "  << prawy << " \n";
		if (sr == lewy) {
			if (testl(wiel,lewy)) {
				cout << lewy << "\n";
				return 0;
			} else {
				cout << prawy << "\n";
				return 0;
			};
		} else {
				if (testl(wiel, sr))
					prawy = sr;
				else
					lewy = sr;
		}
	}
	cout << 1 << "\n";
	// cout << 1 << " == " << testl(wiel, 1) << "\n";
	// cout << 2 << " == " << testl(wiel, 2) << "\n";
	// cout << 3 << " == " << testl(wiel, 3) << "\n";
	// for (auto i: wiel)
        // cout << i<< " ";
	// cout << "\n";
		// for (auto i: wm) 
			// cout << i.second << " ";
		// cout << " koniec\n";
}
        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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85  | #include<iostream> #include <vector> #include <map> #include<algorithm> using namespace std; map<int,int> wyst; vector<int> wiel; bool testl(const vector<int> &wiel, int licz) { vector<int> wm; int ind, fv; ind = 0; for (auto i: wiel) { if (ind >= licz) wm.push_back(i); ind++; } ind = 0; for (int lid = 0; lid < licz; lid++) { fv = wiel[lid]; while (ind < wm.size()) { if (wm[ind] < fv) { fv -= wm[ind]; ind++; } else { wm[ind] -= (fv - 1); break; } }; } return wm.size() == ind; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int liczba, el; cin >> liczba; for (int i=0; i < liczba; i++) { cin >> el; wyst[el]+=1; } for (auto i: wyst) wiel.push_back(i.second); sort(wiel.begin(), wiel.end(), greater<int>()); int lewy, prawy, sr; lewy = 1; prawy = liczba; while (lewy < prawy) { sr = (lewy + prawy)/2; // cout << lewy << " " << sr << " " << prawy << " \n"; if (sr == lewy) { if (testl(wiel,lewy)) { cout << lewy << "\n"; return 0; } else { cout << prawy << "\n"; return 0; }; } else { if (testl(wiel, sr)) prawy = sr; else lewy = sr; } } cout << 1 << "\n"; // cout << 1 << " == " << testl(wiel, 1) << "\n"; // cout << 2 << " == " << testl(wiel, 2) << "\n"; // cout << 3 << " == " << testl(wiel, 3) << "\n"; // for (auto i: wiel) // cout << i<< " "; // cout << "\n"; // for (auto i: wm) // cout << i.second << " "; // cout << " koniec\n"; }  | 
            
        
                    English