
ZOJ Problem Set  3424
The princess is trapped in a magic place. In this place, there are N magic stones. In order to rescue the princess, you should destroy all the stones. The N stones are in a straight line. We number them as s_{1}, s_{2}, ... s_{n} from left to right. Each stone has a magic strength m_{1}, m_{2}, ... m_{n}. You have a powerful skill that can do some damage to the stones. To release the skill, you should stand to the right of some stone (s_{i}). Then you throw a power ball towards left. Initially, this ball has a power of p. When it hits a stone, it will do some damage to the stone and its power will be decreased, and the ball will continue to fly left to the next stone if its power is still positive. Formally, if you stand to the right of s_{i} and the power ball's initial power is p, then the ball will do Max(0, p  (i  j) * (i  j)) damage to s_{j}, for each j <= i. So from this formula, we can see that the damage to stone s_{j} is only determined by the initial power of the ball and the number of stones between s_{i} and s_{j}. A stone is destroyed if the accumulated damage you do is larger than its magic strength. Note that even if a stone is destroyed, it will not disappear; your magic ball will do damage to it and the power will be decreased by that stone. You are not strong enough so that you can release at most k magic balls. It will cost a lot of energy if the power of the magic ball is too high. So what is the minimum value of p with which you can destroy all the magic stones, with no more than k magic balls? You can choose where to release each magic ball as your will, and the power of the ball must be a positive integer. InputThe first line is the number of cases T (T ≤ 100). For each case, the first line gives two integers n, k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 100000). The second line are n integers, giving m_{1}, m_{2}, ... m_{n} (1 ≤ m_{i} ≤ 10^{9}). OutputPrint minimum possible p in a line. Sample Input2 1 1 1 3 1 1 4 5 Sample Output2 6 Author: HANG, Hang Source: The 2010 ACMICPC Asia Chengdu Regional Contest 