~/algor $ cat problems/ikki-korsatkich-qismlar-soni
Segments with sum at most s
Medium
1000 ms
128 MB
62%
A positive integer $n$, an array $a$ of $n$ positive integers and a positive integer $s$ are given. Determine how many segments of consecutive elements (of at least one element) have a sum not exceeding $s$.
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 number of segments.
Note
$1 \le n \le 10^{5}$
$1 \le a_{i} \le 10^{4}$
$1 \le s \le 10^{9}$
Examples
Input #1
3 3 1 2 3
Output #1
4
Input #2
5 10 4 4 4 4 4
Output #2
9