#K7581. Minimum Number of Groups for Trail Distances
Minimum Number of Groups for Trail Distances
Minimum Number of Groups for Trail Distances
You are given a series of trails with specific distances. The goal is to partition the trails into the minimum number of groups such that the sum of distances in each group does not exceed a given threshold (d).
Formally, you are provided with (n) trails described by distances (t_1, t_2, \ldots, t_n) and a maximum allowed distance (d) per group. Your task is to determine the smallest number of groups needed so that the total distance of each group is at most (d).
inputFormat
The input is given via standard input. The first line contains two integers (n) and (d), where (n) is the number of trails and (d) is the maximum allowed distance for each group. If (n > 0), the second line contains (n) integers representing the distances of the trails.
outputFormat
Output a single integer denoting the minimum number of groups required.## sample
5 10
1 2 3 4 5
2
</p>