File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ //(Div. 3 - A) - Three Pairwise Maximums
2
+
3
+ package main
4
+
5
+ import (
6
+ "bufio"
7
+ "fmt"
8
+ "os"
9
+ "strconv"
10
+ )
11
+
12
+ func main () {
13
+ scanner := bufio .NewScanner (os .Stdin )
14
+ scanner .Split (bufio .ScanWords )
15
+ scanner .Scan ()
16
+ t ,_ := strconv .Atoi (scanner .Text ())
17
+ for t > 0 {
18
+ var result int = - 1
19
+ scanner .Scan ()
20
+ n ,_ := strconv .Atoi (scanner .Text ())
21
+ scanner .Scan ()
22
+ m ,_ := strconv .Atoi (scanner .Text ())
23
+
24
+ a1 := make ([]int , n )
25
+ a2 := make ([]int , m )
26
+ for i := 0 ;i < n ;i ++ {
27
+ scanner .Scan ()
28
+ a1 [i ], _ = strconv .Atoi (scanner .Text ())
29
+ }
30
+ for i := 0 ;i < m ;i ++ {
31
+ scanner .Scan ()
32
+ a2 [i ], _ = strconv .Atoi (scanner .Text ())
33
+ }
34
+
35
+
36
+ for i := 0 ;i < n ;i ++ {
37
+ for j := 0 ;j < m ;j ++ {
38
+ if (a1 [i ]== a2 [j ]){
39
+ result = a1 [i ]
40
+ break
41
+ }
42
+ }
43
+ if (result != - 1 ){
44
+ break
45
+ }
46
+ }
47
+ if (result == - 1 ){
48
+ fmt .Println ("NO" )
49
+ }else
50
+ {
51
+ fmt .Println ("YES" )
52
+ fmt .Println (1 ,result )
53
+ }
54
+
55
+ t --
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments