Skip to content

Commit 5b64974

Browse files
authored
[20250204] BOJ / 골드5 / 주사위 쌓기 / 권혁준
1 parent 95b2ba7 commit 5b64974

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
```java
2+
3+
import java.util.*;
4+
import java.io.*;
5+
6+
class Main {
7+
8+
// IO field
9+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
11+
static StringTokenizer st;
12+
13+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
14+
static int nextInt() {return Integer.parseInt(st.nextToken());}
15+
static long nextLong() {return Long.parseLong(st.nextToken());}
16+
static void bwEnd() throws Exception {bw.flush();bw.close();}
17+
18+
// Additional field
19+
20+
public static void main(String[] args) throws Exception {
21+
22+
int[][] ch = {
23+
{1,2,3,4},
24+
{0,2,4,5},
25+
{0,1,3,5},
26+
{0,2,4,5},
27+
{0,1,3,5},
28+
{1,2,3,4}
29+
};
30+
int[] op = {5,3,4,1,2,0};
31+
32+
nextLine();
33+
int N = nextInt();
34+
int[][] Dices = new int[N][6];
35+
for(int i=0;i<N;i++) {
36+
nextLine();
37+
for(int j=0;j<6;j++) Dices[i][j] = nextInt();
38+
}
39+
40+
int ans = 0;
41+
for(int t=0;t<6;t++) {
42+
int res = 0;
43+
for(int k=0;k<4;k++) res = Math.max(res, Dices[0][ch[t][k]]);
44+
45+
int prev = Dices[0][t];
46+
for(int i=1;i<N;i++) {
47+
int down = 0;
48+
while(down < 6) {
49+
if(prev == Dices[i][down]) break;
50+
down++;
51+
}
52+
int up = op[down];
53+
int max = 0;
54+
for(int k=0;k<4;k++) max = Math.max(max, Dices[i][ch[up][k]]);
55+
res += max;
56+
prev = Dices[i][up];
57+
}
58+
ans = Math.max(ans, res);
59+
}
60+
61+
bw.write(ans+"\n");
62+
63+
bwEnd();
64+
}
65+
66+
}
67+
68+
```

0 commit comments

Comments
 (0)