values. In one move you may take any element and replace it with two positive integers that add up to it; the two new numbers take its place, in the order you choose. For example, [5, 9] can become [5, 4, 5] or [2, 3, 9].
Return the smallest number of moves after which the array is non-decreasing, meaning every element is at most the one after it.values=[4, 10, 3] → 4
The trailing 3 stays. 10 has to become at least 4 parts of size at most 3; choosing 2, 2, 3, 3 (three splits) keeps the leftmost part as large as possible. The 4 in front is still bigger than 2, so it becomes 2, 2 (one split). That makes 3 + 1 = 4 splits.
values=[1, 2, 2, 7] → 0
The array is already non-decreasing, so nothing needs splitting.
values=[6, 2] → 2
values=[4, 10, 3]
4
Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.