#C11977. Minimum Number of Containers
Minimum Number of Containers
Minimum Number of Containers
You are given N items with corresponding weights and a container that can hold a maximum weight of W. Your task is to determine the minimum number of containers required to store all items under the following rule:
Load items sequentially. If an item can be added to the current container without exceeding the maximum weight limit (W), place it there; otherwise, start using a new container.
This can be summed up as: for each item weight w, if current\_weight + w \leq W then update current\_weight; else, increment the container count and start with w in a fresh container.
inputFormat
The first line of input contains two integers N and W separated by a space, where 1 ≤ N ≤ 105 and 1 ≤ W ≤ 109.
The second line contains N integers, representing the weights of the items. Each weight lies in the range [1, W].
outputFormat
Output a single integer representing the minimum number of containers required.
## sample5 10
1 2 3 4 5
2