The following combination
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given a set of integers from 1 to n. Consider a subset of the set consisting of k elements, in ascending order.
Print the lexicographically next subset of k elements.
Input
The first line contains the positive integers n and k (1 ≤ k ≤ n ≤ 50). The second line contains k integers from 1 to n in ascending order - a subset of k elements.
Output
Print the lexicographicaly next subset of k elements. If there is no such subset, print 0.
Examples
Input #1
Answer #1
Submissions 256
Acceptance rate 45%