-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
49 lines (47 loc) · 749 Bytes
/
A.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
#include "bits/stdc++.h"
using namespace std;
void solve() {
int n;
scanf("%d", &n);
map <int, int> cnt;
for(int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
cnt[-x] += 1;
}
int ans = 0, g = 0;
vector <int> v;
for(auto i : cnt) {
if(i.second + ans <= (n / 2)) {
ans += i.second;
v.push_back(i.second);
} else break;
}
if(v.empty()) {
printf("0 0 0\n");
return ;
}
g = v[0];
int cur = 1;
int s = 0, b = 0;
while(cur < v.size() && s <= g) {
s += v[cur++];
}
while(cur < v.size()) {
b += v[cur++];
}
if(g < s && g < b && g > 0) {
printf("%d %d %d\n", g, s, b);
} else {
printf("0 0 0\n");
}
}
int main(int argc, char const *argv[])
{
int t;
scanf("%d", &t);
while(t--) {
solve();
}
return 0;
}