Alley
Time limit5sMemory limit256 MB
For each k, find the smallest possible largest gap between adjacent trees after planting k more trees at integer points along the alley.
- Level
Medium7 of 10
- Topics
- Binary search, Greedy, Math
- Solved
- No attempts yet
Problem
Borya recently dreamed that he was walking down a very long alley. Trees grew along it, and the distance between any two trees is an integer number of meters. A tree stands at the very beginning and at the very end of the alley.
Borya loves mathematics, so he decided to rate the beauty of the alley with a single number. He computed the largest distance between two adjacent trees. He calls this number the unevenness of the alley. The smaller the unevenness, the more beautiful the alley is in Borya's opinion.
The alley was so long that Borya's walk dragged on, and he wondered how beautiful the alley could become if he planted more trees along it. To keep the harmony, the distance between every pair of trees must be an integer number of meters. Several trees may be planted at the same point, including points where trees already grow. Help Borya find the minimum unevenness for various values of .
Input
The first line contains three integers , , and (, ): the number of trees already planted, the number of values of that interest Borya, and the length of the alley.
The second line contains integers (), where is the distance in meters from the beginning of the alley to the -th tree.
The third line contains integers (), Borya's queries.
Output
Print real numbers, the minimum unevenness if more trees are planted, respectively. Print each number on its own line.