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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <bits/stdc++.h>

using namespace std;

#define ll long long

template<class T>
int ssize(T &c)
{
	return (int)c.size();
}

template<class T>
istream &operator>>(istream &is, vector<T> &vec)
{
	for (auto &v : vec)
		is >> v;

	return is;
}

template<class T>
auto operator<<(ostream &os, T &x)->decltype(x.end(), os);

template<class A, class B>
auto &operator<<(ostream &o, pair<A,B> &x)
{
	return o << "(" << x.first << " " << x.second << ")";
}

template<class T>
auto operator<<(ostream &os, T &x)->decltype(x.end(), os)
{
	os << "{";
	int i = 2;
	for(auto &e : x)
		os << (", ") + i << e, i = 0;

	return os << "}";
}

auto &operator<<(ostream &os, string &x)
{
	return os << x.c_str();
}

#ifdef DEBUG
#define LOG(x...) cerr << "["#x"]: ", [](auto... e){ ((cerr << e << "; "), ...) << "\n"; }(x)
#else
#define LOG(x...) 0
#endif

#define written_by return
#define efindus
#define in_2024 0

int main()
{
	cin.tie(NULL)->sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> data(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		a--;

		data[a]++;
	}

	sort(data.begin(), data.end());

	int res = 0, l = 0, r = n;
	while (l != r) {
		res++, r--;

		int subtotal = 0;
		while (l != r) {
			if (subtotal + data[l] >= data[r]) {
				data[l] -= data[r] - subtotal - 1;
				break;
			} else {
				subtotal += data[l];
				++l;
			}
		}
	}

	cout << res << "\n";

	written_by efindus in_2024;
}