Multiple of N (1)
InterviewTime limit2sMemory limit512 MB
Given 2N-1 numbers, find N of them whose sum is divisible by N, or report that none exists.
- Level
Medium6 of 10
- Topics
- Combinatorics, Prefix sum, Math, Greedy
- Solved
- No attempts yet
Problem
You are given numbers. Among them, find numbers whose sum is divisible by .
Input
The first line gives . ()
The second line gives numbers between and inclusive, separated by spaces.
Output
On the first line, print the numbers satisfying the condition, separated by spaces.
If several such sets exist, printing any one of them is accepted. The order of the printed numbers does not matter.
If no set of numbers satisfies the condition, print -1.