You are given an integer array nums and an integer k.
Initially, you have k units of resources and must process every element in nums sequentially from index nums.length
To process an element nums[i], you must have at least nums[i] units of resources. If your current resources are strictly less than nums[i], you must perform replenishment operations until you have enough resources:
Each operation adds k units to your available resources.
The
Processing nums[i] consumes nums[i] units of resources.
Return the minimum total cost required to process all elements in nums.
Constraints:
nums.length
nums[i]
k
You are given an integer array nums and an integer k.
Initially, you have k units of resources and must process every element in nums sequentially from index nums.length
To process an element nums[i], you must have at least nums[i] units of resources. If your current resources are strictly less than nums[i], you must perform replenishment operations until you have enough resources:
Each operation adds k units to your available resources.
The
Processing nums[i] consumes nums[i] units of resources.
Return the minimum total cost required to process all elements in nums.
Constraints:
nums.length
nums[i]
k