-
Notifications
You must be signed in to change notification settings - Fork 530
/
d.go
51 lines (47 loc) · 794 Bytes
/
d.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"bufio"
. "fmt"
"io"
"os"
"sort"
)
// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, out io.Writer) {
in := bufio.NewReader(_r)
var n int
a := [4][]int{}
for i := range a {
Fscan(in, &n)
a[i] = make([]int, n)
for j := range a[i] {
Fscan(in, &a[i][j])
}
sort.Ints(a[i])
}
mi, ans := int(1e9), [4]int{}
o:
for i, b := range a {
for _, v := range b {
mx, res := v, [4]int{}
for j, c := range a {
if j != i {
p := sort.SearchInts(c, v)
if p == len(c) {
continue o
}
res[j] = c[p]
if res[j] > mx {
mx = res[j]
}
}
}
if mx-v < mi {
res[i] = v
mi, ans = mx-v, res
}
}
}
Fprint(out, ans[0], ans[1], ans[2], ans[3])
}
func main() { run(os.Stdin, os.Stdout) }