#C7588. Maximum Consecutive Days Within Budget
Maximum Consecutive Days Within Budget
Maximum Consecutive Days Within Budget
Given an integer n representing the number of days, an integer k representing the maximum total allowed expenses, and an array of n positive integers where each integer represents the expense of a day, determine the maximum number of consecutive days for which the sum of expenses does not exceed k.
Formally, if you have an array \( expenses[0 \ldots n-1] \), find the largest integer \( L \) such that there exists an index \( i \) with \( 0 \leq i \leq n - L \) and \( \sum_{j=i}^{i+L-1} expenses[j] \leq k \). Your task is to implement a solution that reads from standard input and writes to standard output.
Constraints:
- 1 \( \leq n \leq 10^5 \)
- 0 \( \leq k \leq 10^9 \)
- Each expense is a positive integer.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains two space-separated integers: n and k.
- The second line contains n space-separated integers representing the expenses.
outputFormat
Output a single integer, which is the maximum number of consecutive days during which the total expenses do not exceed k. The output should be written to standard output.
## sample5 10
1 2 3 4 5
4
</p>