Skip to content

Commit 59e083d

Browse files
authored
Merge pull request #121 from AlgorithmWithGod/khj20006
[20250214] BOJ / G5 / 작은 벌점 / 권혁준
2 parents 4c71fc3 + b9b69fb commit 59e083d

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
static int NA, NB, NC;
20+
static int[] A, B, C;
21+
22+
public static void main(String[] args) throws Exception {
23+
24+
ready();
25+
solve();
26+
27+
bwEnd();
28+
29+
}
30+
31+
static void ready() throws Exception{
32+
33+
nextLine();
34+
NA = nextInt();
35+
NB = nextInt();
36+
NC = nextInt();
37+
38+
A = new int[NA];
39+
B = new int[NB];
40+
C = new int[NC];
41+
42+
nextLine();
43+
for(int i=0;i<NA;i++) A[i] = nextInt();
44+
nextLine();
45+
for(int i=0;i<NB;i++) B[i] = nextInt();
46+
nextLine();
47+
for(int i=0;i<NC;i++) C[i] = nextInt();
48+
49+
}
50+
51+
static void solve() throws Exception{
52+
53+
54+
Arrays.sort(A);
55+
Arrays.sort(B);
56+
Arrays.sort(C);
57+
58+
int ans = Integer.MAX_VALUE;
59+
for(int i:A) {
60+
int s = 0, e = 0;
61+
while(s<NB && e<NC) {
62+
ans = Math.min(ans, max(i,B[s],C[e]) - min(i,B[s],C[e]));
63+
if(B[s] < C[e]) s++;
64+
else e++;
65+
}
66+
}
67+
bw.write(ans+"\n");
68+
69+
}
70+
71+
static int max(int a, int b, int c) {
72+
return Math.max(a, Math.max(b, c));
73+
}
74+
75+
static int min(int a, int b, int c) {
76+
return Math.min(a, Math.min(b, c));
77+
}
78+
79+
}
80+
81+
```

0 commit comments

Comments
 (0)