Marty wants to get back to the future from the past. The computer in his time machine is broken, so he has to work out the numbers himself and type them in.
Marty has two integer arrays: a[1..n] of length n and b[1..m] of length m. For each bj he needs the largest possible sum al+al+1+⋯+ar over the segments a[l..r] whose elements are all greater than or equal to bj.
A segment is never empty, so l≤r holds and the largest sum can be negative. If no element of a is greater than or equal to bj, no segment satisfies the condition.