-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2.cpp
59 lines (44 loc) · 974 Bytes
/
main2.cpp
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
#include<bits/stdc++.h>
using namespace std;
int opera;
void fun(int now,int need,int copy){
if (need==0)return;
if (copy==0){
opera++;
fun(now,need,now);
return;
}
if(copy>=need){
opera=opera+need;
fun(now+need,0,0);
return;
}
if(copy<need){
opera=opera+copy;
now=now+copy;
need=need-copy;
fun(now, need, 0);
}
}
int main(){
int t;
cin>>t;
while(t--){
int x,num;
map<int,int>m;
cin>>num;
int n=num;
while(n--){
cin>>x;
m[x]++;
}
int max=0;
map<int, int>::iterator itr;
for (itr =m.begin(); itr != m.end(); ++itr) {
if( itr->second>max)max=itr->second;
}
fun(max,num-max,0);
cout<<opera<<endl;
opera=0;
}
}