

choose k non empty disjoint array from an array of n integers. Let sub_sum[i] denotes the sum of elemtes of ith subarray. the beauty of subarray is
1sub_sum[1] +2 * sub_sum[2]+3 * sub_sum[3]+.......+ksub_sum[k]. in other words beauty=summation(i*sub_sum[i])
for 1<=i<=k.
given arr and k. find the maximum possible beauty of the array.if it is not possible to choose
k nonempty disjoint subarray return -1;
Note:
it is not necessary to include every element in a subarray.
n=6
-4
-9
10
1
-3
5
k=3
output
33
Explanation
choose [-4] [10,1],[5]
sub_sum[1]=-4
sub_sum[1]=11
sub_sum[1]=5
beauty = 1*-4+211+35=33
what is solution?