Approach hintTry it first, then revealHide
Sort the levels and collect the gaps larger than x; a gap g needs (g - 1) / x extra students to bridge. Close the cheapest gaps first while k allows, and count the groups that remain.
Sort the levels and collect the gaps larger than x; a gap g needs (g - 1) / x extra students to bridge. Close the cheapest gaps first while k allows, and count the groups that remain.