Skip to content

Commit

Permalink
16498(brute_force)
Browse files Browse the repository at this point in the history
  • Loading branch information
0-tae authored Dec 19, 2022
1 parent c45ec02 commit 010e8a0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 최용태/16498(brute_force).java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.*;
import java.io.*;

public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

public static int[] create(int size) {
return new int[size];
}

public static void fillAndSort(int[] arr) throws IOException {
StringTokenizer a = new StringTokenizer(br.readLine(), " ");
for (int i = 0; i < arr.length; i++) arr[i] = Integer.parseInt(a.nextToken());
Arrays.sort(arr);
}

public static void main(String[] args) throws IOException {
StringTokenizer s = new StringTokenizer(br.readLine(), " ");
int ans=1000000001;
int[] A = create(Integer.parseInt(s.nextToken()));
int[] B = create(Integer.parseInt(s.nextToken()));
int[] C = create(Integer.parseInt(s.nextToken()));

fillAndSort(A);
fillAndSort(B);
fillAndSort(C);

for (int i = 0; i < A.length; i++) {
for (int j = 0; j < B.length; j++) {
for (int k = 0; k < C.length; k++) {
ans=Math.min(Math.abs(Math.max(Math.max(A[i],B[j]),C[k])-Math.min(Math.min(A[i],B[j]),C[k])),ans);
}
}
}
System.out.println(ans);
}
}

0 comments on commit 010e8a0

Please sign in to comment.