Codeforces Round 959 sponsored by NEAR (Div. 1 + Div. 2)
C
Hungry Games
Codeforces
1600
原题
← BD →
翻译中…

Yaroslav is playing a computer game, and at one of the levels, he encountered $n$ mushrooms arranged in a row. Each mushroom has its own level of toxicity; the $i$-th mushroom from the beginning has a toxicity level of $a_i$. Yaroslav can choose two integers $1 \le l \le r \le n$, and then his character will take turns from left to right to eat mushrooms from this subsegment one by one, i.e., the mushrooms with numbers $l, l+1, l+2, \ldots, r$.

翻译中…

The character has a toxicity level $g$, initially equal to $0$. The computer game is defined by the number $x$ — the maximum toxicity level at any given time. When eating a mushroom with toxicity level $k$, the following happens:

翻译中…
  1. The toxicity level of the character is increased by $k$.
  2. If $g \leq x$, the process continues; otherwise, $g$ becomes zero and the process continues.
翻译中…

Yaroslav became interested in how many ways there are to choose the values of $l$ and $r$ such that the final value of $g$ is not zero. Help Yaroslav find this number!

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains an integer $t$ ($1 \le t \le 10^{4}$) — the number of test cases. Then follows the description of the test cases.

翻译中…

The first line of each test case contains two integers $n$, $x$ ($1 \leq n \leq 2 \cdot 10^5, 1 \le x \le 10^9$) — the number of mushrooms and the maximum toxicity level.

翻译中…

The second line of each test case contains $n$ numbers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output a single number — the number of subsegments such that the final value of $g$ will not be zero.

翻译中…

Note

翻译中…

In the first test case, the subsegments $(1, 1)$, $(1, 2)$, $(1, 4)$, $(2, 2)$, $(2, 3)$, $(3, 3)$, $(3, 4)$ and $(4, 4)$ are suitable.

翻译中…

In the second test case, non-zero $g$ will remain only on the subsegments $(1, 1)$ and $(2, 2)$.

翻译中…

In the third test case, on the only possible subsegment, $g$ will be zero.

翻译中…

样例

Input #1
5
4 2
1 1 1 1
3 2
1 2 3
1 6
10
6 3
1 2 1 4 3 8
5 999999999
999999999 999999998 1000000000 1000000000 500000000
Output #1
8
2
0
10
7
InputCopy OutputCopy
题目信息
题号
1994C
时间限制
2 s
内存限制
256 MB
标签
二分
动态规划
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。