The Final Weapon, the Bow
Time limit1sMemory limit512 MB
Cut a circular rubber band at K of M marked notches into K arcs; maximize the shortest arc among the K pieces.
- Level
Medium7 of 10
- Topics
- Binary search, Greedy, Array, Implementation
- Solved
- No attempts yet
Problem
Jihun decided to build a bow himself. A bow has a wooden limb and a string made of rubber, and it is finished by hooking the string onto the limb. His father is a carpenter and makes the limb in whatever length and shape Jihun asks for, so Jihun only has to prepare the rubber for the string.
The rubber band he bought at the stationery store is a loop of circumference . The band has notches cut into it, and the rubber is so tough that it can be cut only at a notch. A notch position is measured from the 12 o'clock direction, which is , and increases by clockwise, so is an integer between and .
A good bow needs a string of layers. Jihun therefore cuts the loop into straight rubber strands, stacks those strands, and hooks them onto the limb. The length of the bow is the length of the shortest strand among them.
Find the longest bow Jihun can make.
The picture below shows the band for , , .

Input
The first line contains the circumference of the band , the number of notches where a cut is possible, and the number of layers the bow needs. All three are integers with , , and .
Each of the next lines contains one notch position , an integer with . The notch positions are distinct and are given in ascending order.
Output
Print the length of the longest bow that can be made. If no bow can be made, print -1.