Array and Operation
InterviewTime limit2sMemory limit512 MB
Given an array and a fixed K, decide if adding K to elements any number of times can turn it into a permutation of 1 to N.
- Level
Easy3 of 10
- Topics
- Greedy, Hash map, Math, Implementation
- Solved
- No attempts yet
Problem
Yeongseon has an array of integers.
Only one operation applies to the array.
- Choose one of the numbers in and add to it.
You can use this operation as many times as you want.
Given the array , write a program that decides whether the operation can turn into an array that contains every number from to exactly once.
Input
The first line contains the array size and the integer . (, )
The second line contains the elements of , separated by spaces. Each element is a natural number not greater than .
Output
Print if the operation can produce an array that contains every number from to exactly once, and otherwise.