values and integers count and min_len. Pick exactly count non-overlapping segments (contiguous subarrays), each at least min_len long, so that the total of all elements inside the chosen segments is as large as possible.
Return that largest total. Elements between segments may be left out.values=[4, -1, 2, -9, 3, 3], count=2, min_len=2 → 11
Take [4, -1, 2] with sum 5 and [3, 3] with sum 6, for 11 in total.
values=[-5, -2, -7], count=3, min_len=1 → -14
Three segments out of three elements means each element on its own: −5 − 2 − 7 = −14.
values=[1, 2, 3, 4], count=1, min_len=3 → 10
values=[4, -1, 2, -9, 3, 3], count=2, min_len=2
11
Run checks the first 3 tests in your browser. Submit checks all 210 tests on the server, hidden ones included.