3987. Minimum Total Cost to Process All Elements
You are given an integer array
numsand an integerk.Initially, you have
kunits of resources.You must process the elements of
numsfrom left to right. To process thei^thelement, you neednums[i]resources.If your available resources are less than
nums[i], you may perform an operation that increases your available resources byk. The value ofkis fixed and does not change throughout the process. The first such operation incurs a cost of 1, the second incurs a cost of 2, and so on.After processing the
i^thelement, your available resources decrease bynums[i].Return an integer denoting the minimum total cost required to process all elements. Since the answer may be very large, return it modulo
10^9 + 7.
1 | class Solution { |