Subarray - MarisaOJ: Marisa Online Judge

Subarray

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $a$ consisting of $n$ integers and an integer $S$, find the longest contiguous subarray in $a$ whose sum does not exceed $S$. ### Input - The first line contains two integers $n, S$. - The second line contains $n$ integers $a_i$. ### Output - Print a single integer representing the length of the longest contiguous subarray that satisfies the condition. If there is no satisfied subarray, print `-1`. ### Constraints - $1 \leq n \leq 2 \times 10^5$. - $0 \leq |a_i|, S\leq 10^9$. ### Example Input: ``` 3 -1 4 -3 2 ``` Output ``` 2 ```