P29715 [洛谷] [COCI2015-2016#6] PUTOVANJE
普及-
题目描述

Problem Description

Mislav loves spending time in the forest because it is full of various fruits, each providing a certain level of satiety. However, he will not allow his total satiety to exceed \( C \).

In the forest, there is a path lined with \( N \) fruits, each with a satiety value \( w_i \). Mislav can start at any fruit position and proceed towards the \( N \)-th fruit. During his journey, if eating the current fruit does not cause his total satiety to exceed \( C \), he will definitely eat it. Otherwise, he will skip it and continue moving forward.

Determine the maximum number of fruits Mislav can eat.

Input Format

The first line contains two integers \( N \) and \( C \).

The second line contains \( N \) integers \( w_i \), representing the satiety value of the \( i \)-th fruit.

Output Format

Output a single integer, which is the maximum number of fruits Mislav can eat.

Sample Input and Output

Sample Input #1

5 5
3 1 2 1 1

Sample Output #1

4

Sample Input #2

7 5
1 5 4 3 2 1 1

Sample Output #2

3

Sample Input #3

5 10
3 2 5 4 3

Sample Output #3

3

Notes

[Sample 1 Explanation]

If Mislav starts eating from the 1st fruit, he can eat the 1st, 2nd, and 4th fruits, totaling 3 fruits. If he starts from the 2nd fruit, he can eat the 2nd, 3rd, 4th, and 5th fruits, totaling 4 fruits.

[Data Range]

For 100% of the data, \( 1 \le N \le 1000 \), \( 1 \le C \le 10^6 \), \( 1 \le w_i \le 1000 \).

[Problem Source]

This problem is translated from COCI 2015-2016 CONTEST #6 T2 PUTOVANJE.

This problem is scored according to the original COCI settings, with a maximum score of 80.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 5 3 1 2 1 1
样例输出
4