codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1174A.md (1159B)


      1 Source: https://codeforces.com/problemset/problem/1174/A
      2 
      3 A. Ehab Fails to Be Thanos
      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 You're given an array $a$ of length $2n$. Is it possible to reorder it in such way so that the sum of the first $n$ elements isn't equal to the sum of the last $n$ elements?
     22 
     23 Input
     24 
     25 The first line contains an integer $n$ ($1 \le n \le 1000$), where $2n$ is the number of elements in the array $a$.
     26 
     27 The second line contains $2n$ space-separated integers $a_1$, $a_2$, $\ldots$, $a_{2n}$ ($1 \le a_i \le 10^6$) — the elements of the array $a$.
     28 
     29 Output
     30 
     31 If there's no solution, print "-1" (without quotes). Otherwise, print a single line containing $2n$ space-separated integers. They must form a reordering of $a$. You are allowed to not change the order.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 3
     39 1 2 2 1 3 1
     40 ```
     41 
     42 Output
     43 
     44 ```
     45 2 1 3 1 1 2
     46 ```
     47 
     48 Input
     49 
     50 ```
     51 1
     52 1 1
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 -1
     59 ```
     60 
     61 Note
     62 
     63 In the first example, the first $n$ elements have sum $2+1+3=6$ while the last $n$ elements have sum $1+1+2=4$. The sums aren't equal.
     64 
     65 In the second example, there's no solution.