A hot-air balloon pilot keeps n identical ballast sacks on hand, each weighing exactly w kilograms. Before a flight, the ground crew calculates that the gondola has a remaining lift budget of capacity kilograms — the total additional weight that can still be loaded without exceeding the balloon's safe lift limit. The pilot wants to load as many of her ballast sacks as possible without the combined weight of the loaded sacks exceeding capacity, and of course she cannot load more sacks than the n she actually owns. Determine the maximum number of ballast sacks she can load.
A single whitespace-separated stream of three integers: n, w, and capacity.
Print a single integer: the maximum number of ballast sacks the pilot can load.
Example 1
Input
10 3 25
Expected
8
Explanation
Each sack weighs 3 kg and the budget is 25 kg, so at most floor(25/3)=8 sacks fit by weight (8*3=24 <= 25, 9*3=27 > 25). She has 10 sacks available, so the weight budget is the binding constraint: answer 8.
Example 2
Input
3 5 100
Expected
3
Explanation
The weight budget of 100 kg would allow floor(100/5)=20 sacks, but she only owns 3 sacks, so the sack count is the binding constraint: answer 3.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →