#K61487. Minimum Boxes
Minimum Boxes
Minimum Boxes
You are given n bottles with specified volumes and an unlimited number of boxes. Each box can hold bottles with a total volume not exceeding a given capacity C. Your task is to determine the minimum number of boxes required to pack all the bottles. Note that a bottle cannot be split between boxes.
The problem can be formulated as finding the minimal number of groups such that the sum of the volumes in each group does not exceed \( C \). This is similar to a bin packing problem where a greedy strategy is acceptable under the provided constraints.
inputFormat
The input consists of three lines:
- The first line contains a single integer ( n ) representing the number of bottles.
- The second line contains ( n ) space-separated integers representing the volumes of the bottles.
- The third line contains a single integer representing the maximum capacity ( C ) of each box.
outputFormat
Output a single integer representing the minimum number of boxes required to pack all the bottles.## sample
5
1 2 3 4 5
5
3