-
Notifications
You must be signed in to change notification settings - Fork 4
/
avarcolaci.cpp
58 lines (51 loc) · 863 Bytes
/
avarcolaci.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 <fstream>
#include <vector>
using namespace std;
int main() {
ifstream in("avarcolaci.in");
size_t no_tests;
in >> no_tests;
vector<int> candidate(no_tests,-1);
for(size_t t = 0; t < no_tests; ++t) {
size_t n;
in >> n;
unsigned k = 0;
for(size_t i = 0; i < 2*n; ++i) {
unsigned val;
in >> val;
if(k==0) {
candidate[t] = val;
k=1;
}
else if(candidate[t] == val) {
k++;
}
else {
k--;
}
}
}
in.close();
in.open("avarcolaci.in");
ofstream out("avarcolaci.out");
in >> no_tests;
for(size_t t = 0; t < no_tests; ++t) {
size_t n;
in >> n;
unsigned count = 0;
for(size_t i = 0; i < 2*n; ++i) {
unsigned val;
in >> val;
if(val == candidate[t]) {
count++;
}
}
if(count > n) {
out << candidate[t] << '\n';
}
else {
out << "Mozart" << '\n';
}
}
return 0;
}