values and three integers cut, halves and cuts. Two moves are available:
- **Halve**: replace an element with half of it, rounded up (7 → 4, 8 → 4). At most halves halvings in total.
- **Cut**: decrease an element by cut, provided it is currently at least cut. At most cuts cuts in total.
Each move can be applied to a given element at most once, but one element may receive both moves, in either order.
Return the smallest possible sum of the array.values=[6, 1, 10], cut=4, halves=1, cuts=1 → 8
For example, halve 10 down to 5 and subtract 4 from 6: that gives [2, 1, 5] with sum 8.
values=[7], cut=3, halves=1, cuts=1 → 1
Order matters: halve first (7 → 4), then subtract 3 (4 → 1). The other way round gives 7 → 4 → 2.
values=[2, 9], cut=10, halves=0, cuts=2 → 11
Both numbers are below 10, so nothing can be subtracted, and no halvings are allowed. The sum stays 11.
values=[6, 1, 10], cut=4, halves=1, cuts=1
8
Run checks the first 3 tests in your browser. Submit checks all 255 tests on the server, hidden ones included.