Tallest safe pallet column

Write codeHard35 min

Your task

A warehouse stacks pallets into one column. Pallet i weighs weight[i] kilograms, and crush[i] is the most weight it can carry above it before it fails. A column is safe when every pallet in it carries no more than its own crush rating, counting the weight of all the pallets above it and not its own weight. You choose which pallets go into the column and in what order, and the pallets left out stay on the floor. Return the largest number of pallets one safe column can hold. The two lists have the same length, every weight is at least one, every crush rating is at least zero, and an empty yard gives 0. Working out the order first is what makes the choice tractable.

Examples

tallest_pallet_column(weight: list[int], crush: list[int]) -> int
Example 1
Inputtallest_pallet_column([3, 2, 5], [10, 2, 1])
Output2
Example 2
Inputtallest_pallet_column([1, 1, 1], [5, 5, 5])
Output3
Example 3
Inputtallest_pallet_column([4, 4], [0, 0])
Output1