Number Selection Game
Time limit2sMemory limit128 MB
Given 2N-1 integers where N is a power of two, select exactly N of them whose sum is divisible by N, using a doubling construction.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Math, Combinatorics, Greedy
- Solved
- No attempts yet
Problem
You are given an integer such that and . Then integers are given.
Choose exactly of the given numbers so that the sum of the chosen numbers is divisible by . Print the chosen numbers. If several answers are possible, print any one of them.
Input
The first line contains .
The second line contains integers. Each integer is between and , inclusive.
Output
On the first line, print numbers separated by spaces whose sum is divisible by .
If several answers are possible, print any one of them. If no such selection exists, print -1.