Cable Master
Time limit1sMemory limit128 MB
Find the largest centimeter-precision length such that cutting all stock cables yields at least K pieces of that length.
- Level
Medium6 of 10
- Topics
- Binary search, Greedy
- Solved
- No attempts yet
Problem
A programming contest is being organized, and every contestant's computer will be wired in a "star" topology to a single central hub. To seat the contestants at an equal distance from the hub and as far apart from one another as possible, several network cables of exactly the same length are needed.
The stock contains cables, and the length of each cable is known to the centimeter. The cable master picks one target piece length and then cuts every cable into pieces of that length with centimeter precision. A cable of length yields at most pieces of length , and any leftover is discarded.
Determine the maximum possible length of a single piece so that equal-length pieces can be cut from the cables in stock. The piece length is chosen with centimeter precision (two digits after the decimal point), and every piece must be at least one centimeter long.
Input
The first line contains two integers and separated by a space. () is the number of cables in stock, and () is the number of pieces required. Each of the following lines contains the length of one cable in meters. Every cable is at least 1 meter and at most 100 kilometers long, and all lengths are given with centimeter precision — exactly two digits after the decimal point.
Output
Print the maximum length, in meters, of the pieces that can be cut from the stock to obtain pieces. Print the value with centimeter precision — exactly two digits after the decimal point.
If it is impossible to cut pieces each at least one centimeter long, print the single number 0.00.