MINDIFF - All about Sorting!
You will be given three sorted arrays. Let’s denote the three arrays as A, B and C.
Your task is fairly very simple. You just have to find one element from each of the three arrays so that (|Ai-Bj| + |Bj-Ck| + |Ck-Ai|) is the smallest. Here Ai is an element from array A. Bj is an element form array B. Ck is an element form array C.
Input
The first line of the input will be an integer T denote the number of test cases.
For each of the test cases there will three integers Na Nb Nc in the first line. Na will denote the size of array A, Nb will denote the size of array B, Nc will denote the size of array C.
In the second line of each test case there will be Na number of integers denoting the elements of array A.
In the third line of each test case there will be Nb number of integers denoting the elements of array B.
In the fourth line of each test case there will be Nc number of integers denoting the elements of array C.
Output
For each test case print the desired result.
Constraints
1 <= t <= 100
1 <= Na, Nb, Nc <= 1000
Each elements of the arrays will be a non-negative number less than 10^9.
Example
Input: 2 3 2 3 2 4 6 5 7 1 3 5 3 5 4 1 3 5 7 8 9 10 11 2 14 20 36 Output: 2 10
hide comments
Rafail Loizou:
2021-02-28 04:29:05
1
|
|
eleonoragr:
2016-04-12 17:28:34
@anyone can you please give me some tricky case? |
Added by: | imranziad |
Date: | 2016-03-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | IAPC Round #1 (Jamil Siam) |