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
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <unordered_map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0;
	cin >> n;
	unordered_map<int,int> h;
	int t=0;
	for(int i = 0; i < n; i++) {
		cin>>t;
		h[t]++;
	}
	vector<pair<int, int>> sh(h.begin(), h.end());
	sort(sh.begin(),sh.end(),
		[](const pair<int,int> a, const pair<int,int> b) {
			return a.second>b.second;
	});
	int ret = 0;
	int i = 0;
	while(n > 0) {
		ret++;
		if(2 * sh[i].second > n) {
			break;
		}
		n -= 2 * sh[i].second - 1;
		i++;
	}
	cout<<ret<<"\n";
	return 0;
}