21 lines
485 B
C++
21 lines
485 B
C++
#include <stdio.h>
|
|
int* stairs = NULL;
|
|
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] <= stairs[i] + H && stairs[j] >= stairs[i] - H) {
|
|
total++;
|
|
}
|
|
}
|
|
}
|
|
printf("%lld", total);
|
|
return 0;
|
|
} |