-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF_1393C.cpp
More file actions
53 lines (45 loc) · 906 Bytes
/
CF_1393C.cpp
File metadata and controls
53 lines (45 loc) · 906 Bytes
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
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <functional>
#include <cstdlib>
#include <list>
#include <iomanip>
#define ll long long
using namespace std;
int main() {
int T;
cin >> T;
for (int t = 0; t < T; t++) {
int n;
cin >> n;
vector<pair<int, int>> v(100001);
int maxOccur = 0;
for (int i = 0; i < n; i++) {
int num;
cin >> num;
v[num] = { v[num].first+1, num };
maxOccur = max(maxOccur, v[num].first);
}
sort(v.begin(), v.end(), greater<>());
int ans = 0;
int numOfMaxOccur = 0;
for (int i=0;i<v.size();i++){
if (v[i].first == maxOccur) {
ans++;
n -= v[i].first;
}
}
ans -= 1;
if (maxOccur != 1) {
ans += n / (maxOccur - 1);
}
cout << ans << endl;
}
}