Given an array of N elements. You have to divide it into K consecutive segments according to following rule-
(a) Suppose array is A[0 . . N] and you have to divide it into K consecutive segments.
(b) All the segments are valid if and only if their intersection is NULL and their union is given array.
© You need to create segments such that maximum of sum of numbers in each segment is minimum.
See the first sample test case for better explanation.
First line of input contains an integer T denoting number of test cases. Each test case is composed of 2 lines. First line contains two integers N and K. Next line contains N space separated integers which are the elements of given array.
For each test case just print one integer, that is the answer to given test case. Answer each test case in a new line.
10 20 30 40 50 60 70 80 90
You can divide the given array A into these 3 segments-
(i) A to A : sum= 150
(ii) A to A : sum= 130
(iii) A to A: sum= 170
Maximum of these sums is 170. There is no other way to choose 3 segments so as to minimize this maximum.