#3366
Minimum Array Sum
expert · 1115 · lc medium +32 · 31% accepted · 171 likes · top 8%
Description
You are given an integer array nums and three integers k, op1, and op2.
You may apply these operations on elements of nums:
- Operation 1: Choose index i and replace nums[i] with ceil(nums[i] / 2). This may be used at most op1 times total, at most once per index.
- Operation 2: Choose index i and subtract k from nums[i], only if nums[i] >= k. This may be used at most op2 times total, at most once per index.
Both operations may be applied to the same index (each at most once).
Return the minimum possible sum of all elements in nums.
Code
1
2
3