#P169. 【例28.3】 数列分段
【例28.3】 数列分段
Description
Given a sequence of positive integers of length , divide it into consecutive segments such that the sum of each segment does not exceed (can be equal to ). Find the minimum number of segments needed to satisfy this requirement.
Input Format
The first line contains two positive integers and , representing the length of the sequence and the maximum sum allowed for each segment.
The second line contains non-negative integers separated by spaces.
Constraints: , .
Output Format
Output a single positive integer representing the minimum number of segments needed.
Sample
5 6
4 2 4 5 13