#K78702. Minimum Processing Time
Minimum Processing Time
Minimum Processing Time
You are given multiple test cases. Each test case consists of a number of requests, each with a processing time, and a fixed number of worker nodes. The task is to determine the minimum possible time required to process all requests if the requests are assigned optimally among the worker nodes. Tasks may be processed concurrently on different workers. If there are at least as many workers as requests, the answer is simply the maximum processing time; otherwise, the tasks are assigned in descending order of processing time to the worker with the least current load.
Mathematically, given (N) tasks with processing times (t_1, t_2, \ldots, t_N) and (M) workers, the minimum processing time is defined as follows:
[
\text{Answer} = \begin{cases}
\max(t_1, t_2, \ldots, t_N) & \text{if } M \ge N, \
\min_{assignment} \max_{worker} \text{load} & \text{if } M < N.
\end{cases}
]
inputFormat
The first line contains an integer (T), the number of test cases. For each test case, the first line contains two integers (N) and (M), where (N) is the number of requests and (M) is the number of workers. The next line contains (N) space-separated integers representing the processing times of each request.
outputFormat
For each test case, output a single integer representing the minimum possible processing time required to process all requests.## sample
4
6 3
8 4 3 5 7 2
5 2
10 10 10 10 10
3 3
4 2 7
4 2
10 10 10 10
10
30
7
20
</p>