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

void clearBiggest(vector<pair<int, int>> &vec) {
    pair<int, int> biggest = vec[0];
    vec.erase(vec.begin());
	int currentCount = 0;
	for(int i=vec.size()-1;i>=0;i--){
        if(vec[i].second + currentCount < biggest.second){
            currentCount += vec[i].second;
            vec.erase(vec.begin() + i);
        } else if (vec[i].second + currentCount >= biggest.second){
            vec[i].second -= (biggest.second - currentCount - 1);
            break;
        }
    }
}

bool compareByValue(const pair<int, int>& a, const pair<int, int>& b) {
    return a.second > b.second;
}

int main() {
	int n, a;
	cin >> n;
	int tab[n];
	map<int, int> liczby;
	for(int i=0;i<n;i++){
		cin >> a;
		liczby[a]++;
	}
	vector<pair<int, int>> vec(liczby.begin(), liczby.end());

    sort(vec.begin(), vec.end(), compareByValue);
    n = 0;
    while(vec.size() > 0){
        n++;
        clearBiggest(vec);
    }
    cout << n;

	return 0;
}