A subsegment is a contiguous piece of the list. In the list [1,2,3,4,5] the subsegments include [1,2,3,4], [2,3] and [3,4]. The list [1,3,4,5] is not a subsegment, because 1 and 3 are not next to each other in the original list.
A subsegment is non-decreasing when it holds no element smaller than the element right before it.
The list [3,1,2,4,2,2,3,6] has these non-decreasing subsegments, among others:
- [3], [1], [2], [4], [2], [2], [3], [6]. A single element cannot decrease.
- [1,2,4]
- [2,2,3,6]
The longest of them is [2,2,3,6], with 4 elements.
Compute the length of the longest non-decreasing subsegment and the sum of its elements. If several non-decreasing subsegments reach the maximum length, answer for the one that starts earliest in the input.