-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path1265C.cpp
More file actions
executable file
·53 lines (44 loc) · 760 Bytes
/
1265C.cpp
File metadata and controls
executable file
·53 lines (44 loc) · 760 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
// Problem Code: 1265C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> award(int n, vector<int>& p) {
int pos = 0;
vector<int> res(3);
n /= 2;
// Gold
while (pos < n && p[0] == p[pos]) {
res[0]++;
pos++;
}
// Silver
while (pos < n && (res[0] >= res[1] || p[pos - 1] == p[pos])) {
res[1]++;
pos++;
}
// Bronze
while (p[pos] != p[n]) {
res[2]++;
pos++;
}
if (res[0] >= res[2])
fill(res.begin(), res.end(), 0);
return res;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> res, p(n);
for (int i = 0; i < n; i++)
cin >> p[i];
res = award(n, p);
for (int i = 0; i < res.size(); i++)
cout << res[i] << " ";
cout << endl;
}
return 0;
}