#BS0000382. Chia bánh (Pie)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chia bánh (Pie)
Pie
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
For a birthday party, the host has cylindrical pies of height 1; pie has radius . There are guests. Each guest and the host must receive one piece of the same volume, although the shapes may differ.
Each piece must come from a single pie, not a combination of pieces from different pies. A whole pie may be served and leftovers are allowed. Find the maximum volume of each piece that can serve all people.
Input
The first line contains two integers . The second line contains integers .
Output
Print the maximum volume per piece. The absolute error must not exceed .
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3 3
4 3 3
Output
25.1327
Explanation
Four pieces are required. The radius-4 pie has volume and supplies two pieces of volume . Each radius-3 pie has volume and supplies one such piece. If a piece exceeds , the three pies supply at most three pieces. Hence the answer is .
Input
1 24
5
Output
3.1416
Explanation
The only pie has volume . There are 24 guests and the host, 25 people in total. Dividing the entire pie evenly gives each person .
Input
10 5
1 4 2 3 4 5 6 5 4 2
Output
50.2655
Explanation
Six pieces are needed. At volume per piece, the three radius-4 pies give three pieces, the two radius-5 pies give two, and the radius-6 pie gives two. Six of the seven pieces can be selected. Above , pies of radius at most 4 give no piece and the other three pies give at most four. Thus the optimum is .