-
Notifications
You must be signed in to change notification settings - Fork 7
/
Main.java
81 lines (71 loc) · 1.36 KB
/
Main.java
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package basicLevel1018;
// Please use C Plus Plus.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] states = new int[3];
int JB = 0, JC = 0, JJ = 0;
int YB = 0, YC = 0, YJ = 0;
for (int i = 0; i < n; i++) {
char a = in.next().charAt(0);
char b = in.next().charAt(0);
if (a == 'B') {
if (b == 'B') {
states[1]++;
} else if (b == 'C') {
states[0]++;
JB++;
} else {
states[2]++;
YJ++;
}
} else if (a == 'C') {
if (b == 'B') {
states[2]++;
YB++;
} else if (b == 'C') {
states[1]++;
} else {
states[0]++;
JC++;
}
} else {
// a == 'J'
if (b == 'B') {
states[0]++;
JJ++;
} else if (b == 'C') {
states[2]++;
YC++;
} else {
states[1]++;
}
}
}
in.close();
System.out.println(states[0] + " " + states[1] + " " + states[2]);
System.out.println(states[2] + " " + states[1] + " " + states[0]);
int max = JB;
char symbol = 'B';
if (max < JC) {
max = JC;
symbol = 'C';
}
if (max < JJ) {
symbol = 'J';
}
System.out.print(symbol + " ");
max = YB;
symbol = 'B';
if (max < YC) {
symbol = 'C';
max = YC;
}
if (max < YJ) {
symbol = 'J';
}
System.out.print(symbol);
}
}