🍰Highest blade that still meets the amount?
Cutting all cakes at blade height H slices off the tops of cakes taller than H, gathered for tasting. Find the maximum H where the collected amount is at least 18.
Loading...
Cutting all cakes at blade height H slices off the tops of cakes taller than H, gathered for tasting. Find the maximum H where the collected amount is at least 18.
A dessert shop owner lines up cakes of all different heights on the display shelf. To set up a free tasting corner for customers, the owner sets the cutter's blade to some height H and slices all the cakes horizontally at once. Any cake taller than H has its top sliced off, and all those sliced tops are gathered as tasting pieces. (Cakes shorter than H are untouched by the blade and stay intact.) The lower the blade H, the more is cut and the more tasting pieces you get—but the display cakes get ruined. So the owner wants to meet exactly the required tasting amount while keeping the blade as high as possible to minimize damage. Find the maximum blade height H that still gathers at least the required tasting amount.
6 18 15 22 9 18 30 25
19
Cutting at H=19 gives (22-19)+(30-19)+(25-19) = 3+11+6 = 20 ≥ 18, which is enough. At H=20 it is (22-20)+(30-20)+(25-20) = 2+10+5 = 17 < 18, not enough. So the maximum H is 19.