#P2717. 寒假作业

寒假作业

Description

They have nn pieces of winter vacation homework. For each piece, zzy defined a fatigue value aia_i, representing the effort required to copy that assignment.

zzs wants to know how many contiguous groups of assignments have an average fatigue value not less than kk.

In short, given a positive integer sequence of length nn, {ai}\{a_i\}, count the number of contiguous subarrays whose average is not less than kk.

Input Format

The first line contains two integers, the sequence length nn and the given parameter kk.

The second line contains nn integers, where the ii-th integer is aia_i.

Output Format

Output one line with a single integer representing the answer.

3 2
1
2
3

4

Hint

Sample 1 Explanation

There are 66 contiguous subarrays: (1)(1), (2)(2), (3)(3), (1,2)(1,2), (2,3)(2,3), (1,2,3)(1,2,3). Their averages are 11, 22, 33, 1.51.5, 2.52.5, 22. Among them, there are 44 whose average is not less than 22.

Constraints

  • For 20%20\% of the testdata, it is guaranteed that n100n \leq 100.
  • For 50%50\% of the testdata, it is guaranteed that n5000n \leq 5000.
  • For 100%100\% of the testdata, it is guaranteed that 1n1051 \leq n \leq 10^5, 1ai,k1041 \leq a_i, k \leq 10^4.

Translated by ChatGPT 5