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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ile = 0, output = 0;
    cin >> n;
    int tab[n+1];
    bool bol[n+1];
    fill( tab, tab+n, 0 );
    for(int i = 0 ; i < n; i++){
        int input;
        cin >> input;
        tab[input]++;
        if( bol[input] == 0 ){
            bol[input] = 1;
            ile++;
        }
    }

    sort( tab, tab+n , greater<int>() );

    deque<int> v;
    for(int i = 0; i < ile; i++){
        v.push_back( tab[i] );
    }

    while( !v.empty() ){
        int val = v.front();
        v.pop_front();
        if(v.empty()){
            output++;
            break;
        }
        while( val != 0 ){
            int ind = v.size();
            if( v[ind] <= val ){
                val -= v[ind];
                v.pop_back();
                break;
            }
            v[ind] -= val;
            val = 0;
        }
        output++;
    }    
    cout << output;
    return 0;
}