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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void qsort(ll *t, ll p, ll k) {
    if (p >= k) {return;}
    ll pivot = t[(p + k) / 2];
    ll i = p - 1;
    ll j = k + 1;
    while (i<j) {
        do {i++;}
        while (t[i] < pivot);

        do {j--;}
        while (t[j] > pivot);

        if(i<j){swap(t[i], t[j]);}}
    qsort(t, p, j);
    qsort(t, j + 1, k);
}
int main(){
    ll dlugoscciagu;
    cin>>dlugoscciagu;
    ll max[dlugoscciagu+1]{};
    for(ll i=0;i<dlugoscciagu;i++){
        ll b;
        cin>>b;
        max[b]++;
    }
    qsort(max,0,dlugoscciagu);
    ll wynik=0;
    ll index=dlugoscciagu;
    while(dlugoscciagu>0){
        dlugoscciagu=dlugoscciagu-((max[index--]*2)-1);
        wynik++;
    }
    cout<<wynik;
}