As we all know, Coach Gao is a talented chef, because he is able to cook <var>M</var> dishes in the same time. Tonight he is going to have a hearty dinner with his girlfriend at his home. Of course, Coach Gao is going to cook all dishes himself, in order to show off his genius cooking skill to his girlfriend.

To make full use of his genius in cooking, Coach Gao decides to prepare <var>N</var> dishes for the dinner. The <var>i</var>-th dish contains <var>Ai</var> steps. The steps of a dish should be finished sequentially. In each minute of the cooking, Coach Gao can choose at most <var>M</var>different dishes and finish one step for each dish chosen.

Coach Gao wants to know the least time he needs to prepare the dinner.

Input

There are multiple test cases. The first line of input contains an integer <var>T</var>indicating the number of test cases. For each test case:

The first line contains two integers <var>N</var> and <var>M</var> (1 <= <var>N</var>, <var>M</var> <= 40000). The second line contains <var>N</var> integers <var>Ai</var> (1 <= <var>Ai</var> <= 40000).

Output

For each test case, output the least time (in minute) to finish all dishes.

Sample Input

2
3 2
2 2 2
10 6
1 2 3 4 5 6 7 8 9 10

Sample Output

3
10

题目大意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间。

思维题,以平均值来做菜,所用的时间总是最短。

// Asimple
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <queue> #include <vector> #include <string> #include <cstring> #include <stack> #define INF 0x3f3f3f3f #define mod 7 using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn = 20000+5; int n, m, T, len, cnt, num; void input() { cin >> T; while( T -- ) { cin >> n >> m; int Max = 0; int sum = 0; for(int i=0; i<n; i++) { cin >> num; sum += num; Max = max(Max, num); } cnt = sum/m; if( sum%m ) cnt ++; if( cnt < Max ) cnt = Max; if( m >= n ) cout << Max << endl; else cout << cnt << endl; } } int main() { input(); return 0; }