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

int main(){
    int n;
    cin >> n;
    int T[n+1];
    for (int i = 1; i <= n;i++){
        T[i] = 0;
    }
    for (int i = 1; i <= n;i++){
        int a;
        cin >> a;
        T[a]++;
    }
    vector <int> V;
    int rez = 0;
    for (int i = 1; i <= n;i++){
        if(T[i] != 0){
            V.push_back(T[i]*-1);
        }
    }
    sort(V.begin(),V.end());
    int licznik = 0;
    int i = 0;
    while(licznik < n){
        licznik += -2 * V[i] - 1;
        rez++;
        i++;
    }
    cout << rez;
    }