values. Cut it into three non-empty consecutive pieces: every element lands in exactly one piece and the order is kept.
The price of a piece is its **first** element. The price of the cut is the sum of the prices of the three pieces.
Return the lowest possible price of a cut.values=[7, 9, 2, 6, 3] → 12
Cut it as [7, 9], [2, 6], [3] for a price of 7 + 2 + 3 = 12. The first piece always starts with 7, so the other two should start at the smallest numbers.
values=[4, 4, 4] → 12
There is only one way, one number per piece: 4 + 4 + 4 = 12.
values=[1, 20, 5, 8, 30] → 14
values=[7, 9, 2, 6, 3]
12
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.