Submission #1166695

#TimeUsernameProblemLanguageResultExecution timeMemory
1166695tamyteRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms328 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...