From 010e8a006d9b5b61a34d86ae78c1bfe0cbcc10dc Mon Sep 17 00:00:00 2001 From: 0-tae <100774819+0-tae@users.noreply.github.com> Date: Mon, 19 Dec 2022 18:25:23 +0900 Subject: [PATCH] 16498(brute_force) --- .../16498(brute_force).java" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\354\265\234\354\232\251\355\203\234/16498(brute_force).java" diff --git "a/\354\265\234\354\232\251\355\203\234/16498(brute_force).java" "b/\354\265\234\354\232\251\355\203\234/16498(brute_force).java" new file mode 100644 index 00000000..87b08ed2 --- /dev/null +++ "b/\354\265\234\354\232\251\355\203\234/16498(brute_force).java" @@ -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); + } +}