21 lines
509 B
C++
21 lines
509 B
C++
#include <stdio.h>
|
|
int stairs[100000] = {0};
|
|
int M, K, H;
|
|
long long total = 0;
|
|
|
|
int main() {
|
|
scanf("%d %d %d", &M , &K, &H);
|
|
// stairs = new int[M];
|
|
for (int i = 0; i < M ; i++) {
|
|
scanf("%d", &stairs[i]);
|
|
}
|
|
for (int i = 0; i < M; i++) {
|
|
for (int j = i + 1; j <= i + K && j < M; j++) {
|
|
if (stairs[j] <= ((long long)stairs[i]) + H && stairs[j] >= stairs[i] - H) {
|
|
total++;
|
|
}
|
|
}
|
|
}
|
|
printf("%lld\n", total);
|
|
return 0;
|
|
} |