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

#define def_times(a, b) int a = 0; a<b; a++
#define lol long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    vector<int> count(n, 0);
    for(def_times(i, n)) {
        int tmp;
        cin >> tmp;
        count[tmp-1]++;
    }
    sort(count.begin(), count.end(), [](int l, int r){return l > r;});
    int sum = 0, i = 0;
    while(true) {
        sum += count[i]*2-1;
        i++;
        if(sum >= n) {
            cout << i;
            break;
        };
    }
}