side × side cells. Each cell holds at most one crate, and every crate weighs exactly weight.
The total weight of the loaded crates must not exceed the ship's capacity capacity.
Return the largest number of crates that can be loaded.side=3, weight=4, capacity=50 → 9
The deck has 9 cells, and all 9 crates weigh 36, which is within 50.
side=4, weight=7, capacity=30 → 4
There are 16 cells, but 5 crates would weigh 35 > 30, so only 4 fit.
side=1, weight=10, capacity=9 → 0
side ≤ 1000weight ≤ 1000capacity ≤ 10⁹side=3, weight=4, capacity=50
9
Run checks the first 3 tests in your browser. Submit checks all 114 tests on the server, hidden ones included.