stacks[i] is listed from top to bottom: stacks[i][0] is its top coin.
In one move you may take the top coin of any stack and pocket it. Make exactly picks moves so that the coins in your pocket are worth as much as possible, and return that total.
A coin deep inside a stack can only be reached after every coin above it has been taken.stacks=[[4, 50, 2], [9, 10]], picks=2 → 54
Taking from the tops (4 + 9 = 13, or 9 + 10 = 19) loses to 4 + 50 = 54 from the first stack: to reach the 50 you first take the 4.
stacks=[[20], [20], [1, 1, 90]], picks=3 → 92
It pays to take the whole third stack, 1 + 1 + 90 = 92, rather than both 20s and a 1 (41).
stacks=[[7, 3]], picks=1 → 7
stacks=[[4, 50, 2], [9, 10]], picks=2
54
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.