|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
Garland decorator is a profession which recently gained in importance, especially during Christmas time. Any kid can decorate a christmas tree, any parent can put gifts in sockets, and even anyone can start believing in Santa Claus, but hanging christmas garlands is a completely different story. As you will learn, it is an extremely important, responsible and tough job.
A garland consists of n pieces of equal length. Due to decorations like christmas balls attached to garlands, piece i has its own weight wi . The garland has to be attached to the ceiling in m spots, where the very beginning of the garland should be attached to spot 1 and its end to spot m. The garland should also be hooked to the remaining spots, which divides it into segments, each consisting of several consecutive pieces. There are, however, several rules that every respectable garland decorator should keep in mind.
An example of an optimally hanging garland (consisting of twelve pieces in three segments) is presented below; weights of respective pieces are given in circles.
The input contains several test cases. The first line of the input contains a positive integer Z ≤ 50, denoting the number of test cases. Then Z test cases follow.
The description of each garland consists of two lines. The first line describing a particular garland contains three positive integers n, m, and d (1 ≤ n ≤ 40000, 2 ≤ m ≤ 10000, 1 ≤ d ≤ 10000) separated by single spaces and described above. The second line contains n positive integers w1, w2, . . . , wn (1 ≤ wi ≤ 10000), being the weights of the corresponding pieces.
For each garland, your program should output a single line containing one integer, being the weight of the heaviest half-segment in an optimal attachment of the garland. If it is not possible to hang the garland satisfying conditions (i) and (ii), then your program should output word
4 4 3 10 10 10 20 20 6 4 10 1 1 100 100 1 1 6 3 10 1 1 100 100 1 1 1 2 2 333
20 100 200 BAD