P2717 Winter Vacation Homework
Background
zzs and zzy are being tormented by their winter vacation homework, but they have answers they can copy.
Description
They have $n$ pieces of winter vacation homework. For each piece, zzy defined a fatigue value $a_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 $k$.
In short, given a positive integer sequence of length $n$, $\{a_i\}$, count the number of **contiguous** subarrays whose average is not less than $k$.
Input Format
The first line contains two integers, the sequence length $n$ and the given parameter $k$.
The second line contains $n$ integers, where the $i$-th integer is $a_i$.
Output Format
Output one line with a single integer representing the answer.
Explanation/Hint
#### Sample 1 Explanation
There are $6$ contiguous subarrays: $(1)$, $(2)$, $(3)$, $(1,2)$, $(2,3)$, $(1,2,3)$. Their averages are $1$, $2$, $3$, $1.5$, $2.5$, $2$. Among them, there are $4$ whose average is not less than $2$.
#### Constraints
- For $20\%$ of the testdata, it is guaranteed that $n \leq 100$.
- For $50\%$ of the testdata, it is guaranteed that $n \leq 5000$.
- For $100\%$ of the testdata, it is guaranteed that $1 \leq n \leq 10^5$, $1 \leq a_i, k \leq 10^4$.
Translated by ChatGPT 5