forked from andreimargeloiu/Competitive-programming-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
avarcolaci.cpp
40 lines (40 loc) · 915 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
# include <cstdio>
using namespace std;
int i,j,n,m,t,apmaj,maj,x,VV;
int V[20];
int main ()
{
freopen ("avarcolaci.in", "r", stdin);
freopen ("avarcolaci.out", "w", stdout);
scanf ("%d", &t);
for (i=1; i<=t; ++i)
{
scanf ("%d", &n);
maj=0; apmaj=0;
for (j=1; j<=2*n; ++j)
{
scanf ("%d", &x);
if (x==maj) ++apmaj;
else {
if (apmaj==0) apmaj=1, maj=x;
else --apmaj;
}
V[i]=maj;
}
}
fclose(stdin);
freopen ("avarcolaci.in", "r", stdin);
scanf ("%d", &t);
for (i=1; i<=t; ++i)
{
scanf ("%d", &n); VV=0;
for (j=1; j<=2*n; ++j)
{
scanf ("%d", &x);
if (x==V[i]) ++VV;
}
if (VV>=n+1) printf ("%d\n", V[i]);
else printf ("Mozart\n");
}
return 0;
}