Battery capacity planning

Write codeMedium28 minTesla style

Your task

A remote relay site runs on solar power with a battery pack and a diesel backup. During hour i the panels deliver harvest[i] units of energy and the equipment draws load[i] units. The pack starts the day full. At the end of each hour its charge moves by harvest[i] minus load[i]. Charge above the pack capacity is lost, and any shortfall below zero is covered by the generator, which burns one unit of fuel per unit supplied and leaves the pack empty. Return the smallest whole capacity that keeps the generator's fuel for the whole day at or below budget. The two lists have the same length, every value is non-negative, and budget is non-negative.

Examples

smallest_pack_capacity(harvest: list[int], load: list[int], budget: int) -> int
Example 1
Inputsmallest_pack_capacity([10, 0], [0, 6], 0)
Output6
Example 2
Inputsmallest_pack_capacity([0, 0], [3, 4], 2)
Output5
Example 3
Inputsmallest_pack_capacity([9, 9, 9], [1, 2, 3], 0)
Output0