2061B.md (2154B)
1 Source: https://codeforces.com/problemset/problem/2061/B 2 3 B. Kevin and Geometry 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Kevin has $n$ sticks with length $a_1,a_2,\ldots,a_n$. 22 23 Kevin wants to select $4$ sticks from these to form an isosceles trapezoid$^{\text{∗}}$ with a positive area. Note that rectangles and squares are also considered isosceles trapezoids. Help Kevin find a solution. If no solution exists, output $-1$. 24 25 $^{\text{∗}}$An [isosceles trapezoid](https://en.wikipedia.org/wiki/Isosceles_trapezoid) is a convex quadrilateral with a line of symmetry bisecting one pair of opposite sides. In any isosceles trapezoid, two opposite sides (the bases) are parallel, and the two other sides (the legs) are of equal length. 26 27 Input 28 29 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows. 30 31 The first line of each test case contains a single integer $n$ ($4 \le n \le 2\cdot 10^5$). 32 33 The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^8$). 34 35 It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$. 36 37 Output 38 39 For each test case, output $4$ integers — the lengths of sticks. If no solution exists, output $-1$. 40 41 If there are multiple solutions, print any of them. 42 43 Example 44 45 Input 46 47 ``` 48 7 49 50 4 51 52 5 5 5 10 53 54 4 55 56 10 5 10 5 57 58 4 59 60 1 2 3 4 61 62 4 63 64 1 1 1 3 65 66 6 67 68 4 2 1 5 7 1 69 70 6 71 72 10 200 30 300 30 100 73 74 4 75 76 100000000 100000000 1 2 77 ``` 78 79 Output 80 81 ``` 82 5 5 5 10 83 5 5 10 10 84 -1 85 -1 86 1 1 4 5 87 -1 88 100000000 100000000 1 2 89 ``` 90 91 Note 92 93 In the first test case, you can form an isosceles trapezoid with bases of length $5$ and $10$, and two legs of length $5$. 94 95 In the second test case, you can form an isosceles trapezoid with two bases of length $5$ and two legs of length $10$. A rectangle is considered an isosceles trapezoid here. 96 97 In the third test case, there are no sticks with the same length. It's impossible to form an isosceles trapezoid. 98 99 In the fourth test case, it's impossible to form an isosceles trapezoid with a positive area.