~/algor $ cat problems/eng-uzun-qism
Longest segment
Medium
2000 ms
128 MB
53%
A positive integer $n$, an array $a$ of $n$ positive integers and a positive integer $S$ are given. Find the length of the longest contiguous segment of the array (consecutive elements) whose sum does not exceed $S$. If there is no such segment (every element is greater than $S$), print $0$.
Input
The first line contains two positive integers: $n$ and $S$. The second line contains $n$ positive integers $a_{i}$ separated by spaces.
Output
One integer — the length of the longest segment, or $0$.
Note
$1 \le n \le 2 * 10^{5}$
$1 \le a_{i} \le 10^{9}$
$1 \le S \le 10^{15}$
Examples
Input #1
5 7 2 1 3 4 1
Output #1
3
Input #2
3 1 5 6 7
Output #2
0