3077. Maximum Strength of K Disjoint Subarrays
You are given a 0-indexed array of integers
numsof lengthn, and a positive odd integerk.The strength of
xsubarrays is defined asstrength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1wheresum[i]is the sum of the elements in theithsubarray. Formally, strength is sum of(-1)i+1 * sum[i] * (x - i + 1)over alli‘s such that1 <= i <= x.You need to select
kdisjoint subarrays fromnums, such that their strength is maximum.Return the maximum possible strength that can be obtained.
Note that the selected subarrays don’t need to cover the entire array.