#K52737. Optimal Job Scheduling
Optimal Job Scheduling
Optimal Job Scheduling
You are given several test cases where in each test case you have n processing modules and m jobs. Each job is identified by a type. In one minute, each module can process at most one job; however, two jobs of the same type cannot be processed concurrently since they share the same module type resource. Your task is to determine the minimum number of minutes required to complete all jobs if they are assigned optimally.
Formally, for each test case, you are provided with two integers n and m followed by a list of m integers representing job types. Let \(f\) be the maximum frequency of any job type, and let \(\lceil m/n \rceil\) be the minimum number of minutes required if jobs are perfectly balanced across the modules. The answer for each test case is:
[ \text{answer} = \max\left(f, \left\lceil\frac{m}{n}\right\rceil\right) ]
Note: Use the input from stdin and print the output to stdout.
inputFormat
The input begins with an integer t representing the number of test cases. For each test case, the first line contains two space-separated integers n (the number of modules) and m (the number of jobs). The next line contains m space-separated integers, each representing the type of a job.
outputFormat
For each test case, output a single integer on a new line denoting the minimum number of minutes required to process all jobs.
## sample2
2 4
1 2 1 3
3 5
1 2 3 1 2
2
2
</p>