Your are given an array A containing N elements and another array B containing M elements.
You want to separate A into M of non-empty contiguous subsequences such that each element belongs to exactly one subsequence. Moreover, the sum of elements of the r^{th} subsequence where (0<=r