#K88077. Efficient Packet Processing
Efficient Packet Processing
Efficient Packet Processing
You are given a number of test cases. In each test case, you are provided with an integer (P) representing the number of packets and an integer (N) representing the number of servers. Each server has a capacity (c_i) which indicates the number of packets it can process per minute. The goal is to compute the minimum number of minutes required to process all (P) packets if all servers work concurrently. The answer for each test case can be computed using the formula:
[ \text{minutes} = \left\lceil \frac{P}{\sum_{i=1}^{N} c_i} \right\rceil ]
If (\sum_{i=1}^{N} c_i = 0) (i.e. all servers have zero capacity), then the processing time is considered to be infinite. In such cases, output the string "Infinity".
inputFormat
The input is read from standard input (stdin) and consists of multiple test cases. The first line contains an integer (T) indicating the number of test cases. Each test case is described as follows:
- The first line contains two integers: (P) (the number of packets) and (N) (the number of servers).
- The second line contains (N) space-separated integers, where the (i)-th integer is the capacity (c_i) of the (i)-th server.
All input values are provided in a single run.
outputFormat
For each test case, output the minimum number of minutes required to process all packets on a separate line. If the total capacity of all servers is zero, output the string "Infinity".## sample
2
100 5
10 20 30 40 50
200 3
50 50 50
1
2
</p>