409219: GYM103462 K K-Clearing II

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. K-Clearing IItime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

You are given an array $$$a$$$ of $$$n$$$ integers.

While there is at least one element equal to $$$k$$$ in the array, then you should make all the positive elements in the array minus one. In other words, $$$a_i=a_i-1(1\leq i\leq n;a_i > 0)$$$.

Please calculate the sum of the number of elements equal to $$$0$$$ after clear all elements equal to $$$k$$$ in all subarray containing $$$m$$$ consecutive elements in the array $$$a$$$.

Input

The first line contains three integers $$$n,m(1\leq m\leq n\leq 10^6)$$$, $$$k(1\leq k\leq 10^9)$$$ — the length of $$$a$$$, the length of the subarray and the number we need to clear.

The second line contains $$$n$$$ integers $$$ a_1,a_2,...,a_n(1\leq a_i\leq 10^9)$$$.

Output

Output an integer representing the answer.

ExamplesInput
5 3 1
1 2 3 4 5
Output
3
Input
6 3 1
1 1 4 5 1 4
Output
5
Note

In the second sample, there are $$$4$$$ subarrays in $$$a$$$ with length $$$m$$$:

1.$$$[1,1,4]$$$, and $$$[0,0,3]$$$ after clear the $$$k$$$

2.$$$[1,4,5]$$$, and $$$[0,3,4]$$$ after clear the $$$k$$$

3.$$$[4,5,1]$$$, and $$$[3,4,0]$$$ after clear the $$$k$$$

3.$$$[5,1,4]$$$, and $$$[4,0,3]$$$ after clear the $$$k$$$

So the sum of the number of elements equal to $$$0$$$ is $$$5$$$.

加入题单

算法标签: