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
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int a_i[500000];
int sort_lenght[500000];

int main(){
    long n;
    cin >> n;
    long number_elem=n, output=1;
    for(long i=0;i<n;i++){
		cin>>a_i[i];
    }
    sort(&a_i[0],&a_i[n], greater<int>());

    int element_to_comper=a_i[0];
    int ile_w_sort=0;
    for(long i=0;i<n;i++){
	    if (a_i[i]<element_to_comper) {
            element_to_comper = a_i[i];
            ile_w_sort++;
        }
        sort_lenght[ile_w_sort]++;
    }
    sort(&sort_lenght[0],&sort_lenght[ile_w_sort+1], greater<int>());

   for(long i=0;i<ile_w_sort+1;i++){
	//    cout<<sort_lenght[i] <<" " ;
    }
    //cout << endl;
 

    for(long i=0;i<ile_w_sort+1;i++){
        number_elem-= 2*sort_lenght[i] -1;
        if(number_elem <=0) {
            cout << output<< endl;
            return 0;
        }
        output++;
    }
    
    for(long i=0;i<n;i++){
	//    cout<<a_i[i] <<" " ;
    }
    return 0;
 
}