Skip to content

Commit 08a95ce

Browse files
authored
[20250203] BOJ / 골드5 / 주사위 쌓기 / 이강현
1 parent 39170c6 commit 08a95ce

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.BufferedWriter;
4+
import java.io.InputStreamReader;
5+
import java.io.OutputStreamWriter;
6+
import java.util.*;
7+
public class Main {
8+
public static void main(String[] args) throws Exception {
9+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
11+
int N = Integer.parseInt(br.readLine());
12+
int[] diceInput = new int[6];
13+
int[][] Dices = new int[N][7];
14+
for(int i=0;i<N;i++) {
15+
StringTokenizer st = new StringTokenizer(br.readLine());
16+
for (int j = 0; j < 6; j++) {
17+
diceInput[j] = Integer.parseInt(st.nextToken());
18+
}
19+
Dices[i][diceInput[0]] = diceInput[5]; //A F
20+
Dices[i][diceInput[1]] = diceInput[3]; //B D
21+
Dices[i][diceInput[2]] = diceInput[4]; //C E
22+
Dices[i][diceInput[3]] = diceInput[1]; //D B
23+
Dices[i][diceInput[4]] = diceInput[2]; //E C
24+
Dices[i][diceInput[5]] = diceInput[0]; //F A
25+
}
26+
int max = 0;
27+
for(int i=1;i<7;i++){
28+
int bottom = i;
29+
int top = Dices[0][i];
30+
int sum = 0;
31+
if(bottom != 6 && top != 6){ sum = 6;}
32+
else if(bottom != 5 && top != 5) { sum = 5;}
33+
else{sum=4;}
34+
for(int j=1;j<N;j++){
35+
bottom = top;
36+
top = Dices[j][bottom];
37+
if(bottom != 6 && top != 6){ sum += 6;}
38+
else if(bottom != 5 && top != 5) { sum += 5;}
39+
else{sum += 4;}
40+
}
41+
if(max<sum){max = sum;}
42+
}
43+
bw.write(max+"");
44+
bw.flush();
45+
}
46+
}
47+
```

0 commit comments

Comments
 (0)