Skip to content

Commit 5545511

Browse files
authored
[20251011] BOJ / G5 / 주사위 / 이인희
1 parent 7d1bdd4 commit 5545511

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static int N;
7+
private static int[][] exposures3 = {
8+
{0, 1, 2},
9+
{0, 1, 3},
10+
{0, 3, 4},
11+
{0, 4, 2},
12+
{1, 2, 5},
13+
{1, 3, 5},
14+
{1, 0, 3},
15+
{1, 0, 2},
16+
{2, 1, 5},
17+
{2, 0, 1},
18+
{2, 0, 4},
19+
{2, 4, 5},
20+
{3, 0, 1},
21+
{3, 5, 1},
22+
{3, 4, 5},
23+
{3, 4, 0},
24+
{4, 2, 0},
25+
{4, 3, 0},
26+
{4, 3, 5},
27+
{4, 5, 2}
28+
};
29+
private static int[][] exposures2 = {
30+
{0, 1},
31+
{0, 2},
32+
{0, 3},
33+
{0, 4},
34+
{1, 0},
35+
{1, 2},
36+
{1, 5},
37+
{1, 3},
38+
{2, 0},
39+
{2, 1},
40+
{2, 5},
41+
{2, 4},
42+
{3, 0},
43+
{3, 1},
44+
{3, 5},
45+
{3, 4},
46+
{4, 0},
47+
{4, 2},
48+
{4, 3},
49+
{4, 5},
50+
{5, 1},
51+
{5, 2},
52+
{5, 3},
53+
{5, 4}
54+
};
55+
private static int[] Eyes;
56+
57+
public static void main(String[] args)throws IOException {
58+
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
59+
N = Integer.parseInt(br.readLine());
60+
Eyes = new int[6];
61+
StringTokenizer st = new StringTokenizer(br.readLine());
62+
for(int i = 0; i < 6; i++) {
63+
Eyes[i] = Integer.parseInt(st.nextToken());
64+
}
65+
66+
if(N == 1){
67+
System.out.println(Arrays.stream(Eyes).sum() - Arrays.stream(Eyes).max().getAsInt());
68+
return;
69+
}
70+
71+
int min3 = Integer.MAX_VALUE;
72+
int min2 = Integer.MAX_VALUE;
73+
int min1 = Arrays.stream(Eyes).min().getAsInt();
74+
75+
for(int[] exposure2 : exposures2) {
76+
int temp = 0;
77+
for(int i : exposure2) temp += Eyes[i];
78+
min2 = Math.min(temp, min2);
79+
}
80+
81+
for(int[] exposure3 : exposures3) {
82+
int temp = 0;
83+
for(int i : exposure3) temp += Eyes[i];
84+
min3 = Math.min(temp, min3);
85+
}
86+
87+
long nExposure3 = 4;
88+
long nExposure2 = (N - 2) * 8 + 4;
89+
long nExposure1 = (long)(N - 2) * (N - 2) + (long)(N - 2) * 4 * (N - 1);
90+
91+
long answer = min3 * nExposure3 + min2 * nExposure2 + min1 * nExposure1;
92+
System.out.println(answer);
93+
br.close();
94+
}
95+
}
96+
97+
```

0 commit comments

Comments
 (0)