piles and a number moves. Your score starts at 0. In one move you choose any pile, add its size v to the score, and the pile is then left with ⌈v / 3⌉ coins (division by 3 rounded up).
Make exactly moves moves (the same pile may be chosen any number of times) and return the largest possible score.piles=[2, 12, 5], moves=3 → 21
Take 12 (the pile becomes 4), then 5 (becomes 2), then 4. Total 12 + 5 + 4 = 21.
piles=[7], moves=4 → 12
A single pile: 7, then ⌈7/3⌉ = 3, then 1, then 1 again. Total 12.
piles=[6, 6, 6], moves=3 → 18
piles=[2, 12, 5], moves=3
21
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.