#K55802. Optimizing Packet Segmentation
Optimizing Packet Segmentation
Optimizing Packet Segmentation
You are given a sequence of test cases. Each test case describes a set of network packets that need to be transmitted. For a given test case, you are provided:
- An integer N representing the number of packets.
- An integer L representing the maximum segment size.
- A list of N integers, where each integer is the size of a packet.
For each packet with size p, you must determine the minimum number of segments needed so that each segment is at most L. Mathematically, the number of segments needed for a packet is given by:
\( \lceil p / L \rceil \)
Your task is to compute the total number of segments required to send all packets in each test case.
Input/Output Requirement: Read input from stdin and write your output to stdout as described below.
inputFormat
The input begins with a single integer T denoting the number of test cases. For each test case:
- The first line contains two space-separated integers N and L where N is the number of packets and L is the maximum segment size.
- The second line contains N space-separated integers representing the sizes of the packets.
Constraints:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ L, p ≤ 109
outputFormat
For each test case, output a single integer on a new line representing the total number of segments required to send all packets.
## sample5
3 5
8 12 15
2 10
25 30
1 2
1000000000
1 3
10
3 2
4 4 4
8
6
500000000
4
6
</p>