Pie
Time limit1sMemory limit128 MB
Given N cylindrical pies, find the maximum piece volume so that F+1 equal-sized pieces can be cut from the pies, using binary search on the answer.
- Level
Medium5 of 10
- Topics
- Binary search, Math, Greedy
- Solved
- No attempts yet
Problem
My birthday is coming up, and by tradition I serve pie. Not just one pie — I have of them, of various tastes and sizes. friends are coming to the party, and each of them gets one piece of pie. To keep things tidy this must be a single piece cut from one pie, not several small pieces, though a whole pie may count as one piece.
My friends are picky: if anyone gets a bigger piece than the others, they start complaining. So everyone must get an equally sized piece (the shapes may differ), even if this means some pie is wasted. Of course I want a piece for myself too, and it must be the same size.
Every pie is a cylinder of the same height , but the radii may differ. What is the largest volume of piece that I and all of my friends can each get?
Input
The first line contains a positive integer: the number of test cases. Then, for each test case:
- One line with two integers and (): the number of pies and the number of friends.
- One line with integers (): the radii of the pies.
Output
For each test case, output on one line the largest volume such that I and all of my friends can each get a piece of size , rounded to exactly four decimal places. (The original problem allows any real number within an absolute error of ; for automatic judging the answer is printed with a fixed four-decimal format.)