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

using namespace std;
#define turbo ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main() {
    turbo;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map <int, int> mp;
    for (int i = 0; i < n; i++) {
        mp[a[i]]++;
    }
    vector <pair<int, int>> v;
    for (auto i : mp) {
        v.push_back({i.second, i.first});
    }
    sort(v.begin(), v.end(), greater<pair<int, int>>());
    int ans = 0;
    for (int i = 0; i < v.size(); i++) {
        ans += 2 * v[i].first - 1;
        if (ans >= n) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}