#K51952. Maximize Empty Slots
Maximize Empty Slots
Maximize Empty Slots
You are given a shelf with n positions, numbered from 1 to n. Some of these positions are already occupied by books. Your task is to place m new books into the remaining available positions such that the empty slots between any two books are, in a sense, maximized. In this problem, you should choose the smallest available positions in increasing order.
The input will give you the number of total positions n, the number of new books to place m, and the number of already placed books k followed by k sorted integers representing the positions that are already occupied. If m is zero or if all positions are occupied, your output should be empty.
Note: Although the storyline speaks of maximizing empty slots, the intended solution is to simply output the first m available positions in ascending order.
inputFormat
The first line contains three integers separated by spaces: n (the total number of positions on the shelf), m (the number of new books to place), and k (the number of books already placed). The second line contains k space-separated integers in ascending order indicating the positions of the already placed books. If k is 0, the second line will be empty.
outputFormat
Output a single line with m space-separated integers in ascending order representing the positions where the new books should be placed. If m is 0 or if there are no available positions, output an empty line.## sample
5 2 2
1 5
2 3
</p>