310478: CF1840C. Ski Resort

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Ski Resorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Dima Vatrushin is a math teacher at school. He was sent on vacation for $n$ days for his good work. Dima has long dreamed of going to a ski resort, so he wants to allocate several consecutive days and go skiing. Since the vacation requires careful preparation, he will only go for at least $k$ days.

You are given an array $a$ containing the weather forecast at the resort. That is, on the $i$-th day, the temperature will be $a_i$ degrees.

Dima was born in Siberia, so he can go on vacation only if the temperature does not rise above $q$ degrees throughout the vacation.

Unfortunately, Dima was so absorbed in abstract algebra that he forgot how to count. He asks you to help him and count the number of ways to choose vacation dates at the resort.

Input

The first line of the input contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

Then follow the descriptions of the test cases.

The first line of each test case contains three integers $n$, $k$, $q$ ($1 \le n \le 2 \cdot 10^5$, $1 \le k \le n$, $-10^9 \le q \le 10^9$) — the length of the array $a$, the minimum number of days at the resort, and the maximum comfortable temperature for Dima.

The second line of each test case contains $n$ integers $a_1, a_2, a_3, \dots, a_n$ ($-10^9 \le a_i \le 10^9$) — the temperature at the ski resort.

The sum of all $n$ values over all test cases does not exceed $2 \cdot 10^5$.

Output

Output $t$ integers, each of which is the answer to the corresponding test case — the number of ways for Dima to choose vacation dates at the resort.

ExampleInput
7
3 1 15
-5 0 -10
5 3 -33
8 12 9 0 5
4 3 12
12 12 10 15
4 1 -5
0 -1 2 5
5 5 0
3 -1 4 -5 -3
1 1 5
5
6 1 3
0 3 -2 5 -4 -4
Output
6
0
1
0
0
1
9
Note

In the first test case of the example, Dima can go on any day, so the suitable dates for him are [1], [2], [3], [1, 2], [2, 3], [1, 2, 3].

In the second and fourth test cases of the example, Dima cannot go on any day due to the high temperature, so there are no suitable dates.

In the third test case of the example, Dima can only go on the dates [1, 2, 3].

Input

题意翻译

给定 $n$,$k$,$q$ 和一个长度为 $n$ 的序列 $a$。 在 $a$ 中选出一个连续的序列,序列的长度需大于等于 $k$ 并且序列中的最大值小于等于 $q$。 问,共有多少种选法?

Output

题目大意:
Dima Vatrushin是一位数学老师,他因为工作表现出色而获得了n天的假期。他想去滑雪胜地度假,因此他想分配连续的几天去滑雪。由于度假需要精心准备,他只会去至少k天。给定一个数组a,其中包含度假胜地的天气预报,即第i天的温度将是a_i度。Dima出生在西伯利亚,因此只有当整个假期温度不超过q度时,他才会去度假。Dima沉浸在抽象代数中,忘记了如何计算。他请你帮助他计算选择度假日期的方法数。

输入数据格式:
输入的第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。
接下来是测试用例的描述。
每个测试用例的第一行包含三个整数n、k、q(1≤n≤2*10^5,1≤k≤n,-10^9≤q≤10^9)——数组a的长度、度假的最少天数和Dima感到舒适的最大温度。
每个测试用例的第二行包含n个整数a_1,a_2,a_3,…,a_n(-10^9≤a_i≤10^9)——滑雪胜地的温度。
所有测试用例的n值之和不超过2*10^5。

输出数据格式:
输出t个整数,每个整数对应一个测试用例的答案——Dima选择度假日期的方法数。

示例:
输入:
7
3 1 15
-5 0 -10
5 3 -33
8 12 9 0 5
4 3 12
12 12 10 15
4 1 -5
0 -1 2 5
5 5 0
3 -1 4 -5 -3
1 1 5
5
6 1 3
0 3 -2 5 -4 -4
输出:
6
0
1
0
0
1
9题目大意: Dima Vatrushin是一位数学老师,他因为工作表现出色而获得了n天的假期。他想去滑雪胜地度假,因此他想分配连续的几天去滑雪。由于度假需要精心准备,他只会去至少k天。给定一个数组a,其中包含度假胜地的天气预报,即第i天的温度将是a_i度。Dima出生在西伯利亚,因此只有当整个假期温度不超过q度时,他才会去度假。Dima沉浸在抽象代数中,忘记了如何计算。他请你帮助他计算选择度假日期的方法数。 输入数据格式: 输入的第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。 接下来是测试用例的描述。 每个测试用例的第一行包含三个整数n、k、q(1≤n≤2*10^5,1≤k≤n,-10^9≤q≤10^9)——数组a的长度、度假的最少天数和Dima感到舒适的最大温度。 每个测试用例的第二行包含n个整数a_1,a_2,a_3,…,a_n(-10^9≤a_i≤10^9)——滑雪胜地的温度。 所有测试用例的n值之和不超过2*10^5。 输出数据格式: 输出t个整数,每个整数对应一个测试用例的答案——Dima选择度假日期的方法数。 示例: 输入: 7 3 1 15 -5 0 -10 5 3 -33 8 12 9 0 5 4 3 12 12 12 10 15 4 1 -5 0 -1 2 5 5 5 0 3 -1 4 -5 -3 1 1 5 5 6 1 3 0 3 -2 5 -4 -4 输出: 6 0 1 0 0 1 9

加入题单

上一题 下一题 算法标签: