365 传统题

[ABC130D] 足够大的子段 (Enough Array)

时间限制
2000ms
内存限制
1024MiB
登顶 / 尝试
0/ 0
难度
2
    上传者 标签AtCoderABC130普及-双指针前缀和

[ABC130D] 足够大的子段 (Enough Array)

Score : 400400 points

Problem Statement

You are given a sequence of positive integers of length NN, A=a1,a2,…,aNA=a_1,a_2,…,a_{N}, and an integer KK. How many contiguous subsequences of AA satisfy the following condition?

  • (Condition) The sum of the elements in the contiguous subsequence is at least KK.

We consider two contiguous subsequences different if they derive from different positions in AA, even if they are the same in content.

Note that the answer may not fit into a 3232-bit integer type.

Constraints

  • 1≤ai≤1051 \leq a_i \leq 10^5

  • 1≤N≤1051 \leq N \leq 10^5

  • 1≤K≤10101 \leq K \leq 10^{10}

Input

Input is given from Standard Input in the following format:

$N$ $K$
$a_1$ $a_2$ $...$ $a_N$

Output

Print the number of contiguous subsequences of AA that satisfy the condition.

Sample Input 1

4 10
6 1 2 7

Sample Output 1

2

The following two contiguous subsequences satisfy the condition:

  • A[1..4]=a1,a2,a3,a4A[1..4]=a_1,a_2,a_3,a_4, with the sum of 1616

  • A[2..4]=a2,a3,a4A[2..4]=a_2,a_3,a_4, with the sum of 1010

Sample Input 2

3 5
3 3 3

Sample Output 2

3

Note again that we consider two contiguous subsequences different if they derive from different positions, even if they are the same in content.

Sample Input 3

10 53462
103 35322 232 342 21099 90000 18843 9010 35221 19352

Sample Output 3

36