#Q7. 「一本通 1.1 练习 2」数列分段
「一本通 1.1 练习 2」数列分段
Description
Given a positive integer sequence of length , it needs to be divided into contiguous segments such that the sum of each segment does not exceed (it can be equal to ). The task is to find the minimum number of segments required to meet this condition.
Input Format
The first line contains two positive integers and , representing the length of the sequence and the maximum allowed sum for each segment.
The second line contains space-separated non-negative integers .
Output Format
The output file should contain a single positive integer, which is the minimum number of segments required.
Sample 1
5 6
4 2 4 5 1
3
Data Range and Hints
For of the data, ;
For of the data, ;
For of the data, , , and is greater than the maximum value in the sequence.