values and an integer threshold. Call a piece of the array *sturdy* if it has a single element or the sum of its elements is at least threshold.
In one step you may take any existing piece of length at least 2 and cut it into two contiguous pieces, but only if both resulting pieces are sturdy.
You start with one piece, the whole array. Return True if such steps can reach the state where every element is its own piece, and False otherwise.values=[1, 4, 3, 1], threshold=7 → True
Cut off the last 1: [1, 4, 3] (sum 8) and [1]. Then the first 1: [1] and [4, 3] (sum 7). Finally [4, 3] becomes [4] and [3].
values=[3, 1, 3], threshold=5 → False
The first cut leaves either [3, 1] or [1, 3]; that sum of 4 is below 5 and the length is more than 1, so no cut is allowed.
values=[9, 2], threshold=200 → True
values=[1, 4, 3, 1], threshold=7
True
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.