#include <iostream>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int prev_height = 0;
int count = 0;
for (int i = 0; i < N; ++i) {
int a;
cin >> a;
int allowed_max = prev_height + M;
if (a > allowed_max) {
count++;
prev_height = allowed_max;
} else if (a < 0) {
count++;
prev_height = 0;
} else {
prev_height = a;
}
}
cout << count << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |