Multiples of N (2)
Time limit1sMemory limit512 MB
Given 2N-1 integers, each at least 0 and less than N, pick N of them whose sum is divisible by N, or print -1 if none exists.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Array, Divide and conquer
- Solved
- No attempts yet
Problem
You are given numbers. Find of them whose sum is divisible by .
Input
The first line contains ().
The second line contains numbers, each at least and less than , separated by spaces.
Output
Print numbers that satisfy the condition, separated by spaces, on the first line.
If several answers 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.