Help needed in a DP Problem

Revision en3, by Utsavcc, 2024-06-20 08:28:12

Given an array of length N with elements array[i] (negative integers inclusive), maximize the Score of the array.

Score of the array = -seg[1]+seg[2]-seg[3]+seg[4].... where all seg[i] are the sum of non-intersecting segments of the array which constitute all of the array when combined. We are also provided with an integer K, meaning the array must be divided exactly into K segments.

We aren't given constraints in the problem statement. What is the optimised approach for this question.

Could anyone share the solution with DP state[N][K]

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Utsavcc 2024-06-20 08:28:12 57
en2 English Utsavcc 2024-06-19 07:36:07 16
en1 English Utsavcc 2024-06-19 04:33:25 583 Initial revision (published)