5667: Number of Segments with Small Sum
[Creator : ]
Description
Given an array of $n$ integers $a_i$. Let's say that the segment of this array $a[l..r]\ (1≤l≤r≤n)$ is good if the sum of elements on this segment is at most $s$.
Your task is to find the number of good segments.
给定由$n$个数组成的数字序列$a_i$,求子段和小于等于$s$的子段数量
Your task is to find the number of good segments.
给定由$n$个数组成的数字序列$a_i$,求子段和小于等于$s$的子段数量
Input
The first line contains integers $n,\ s\ (1≤n≤10^5,\ 1≤s≤10^{18})$.
The second line contains integers $a_i\ (1≤a_i≤10^9)$.
The second line contains integers $a_i\ (1≤a_i≤10^9)$.
Output
Print one integer, the number of good segments.
Sample 1 Input
7 20
2 6 4 3 6 8 9
Sample 1 Output
19
Sample 2 Input
1 5
5
Sample 2 Output
1