Submission #376492

# Submission time Handle Problem Language Result Execution time Memory
376492 2021-03-11T14:59:33 Z gustason Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 364 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1);
    a[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int best = n+1;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if (a[i] - a[i-1] > m) {
            a[i] = a[i-1] + m;
            ans++;
        }
    }
    best = ans;
    ans = 0;
    reverse(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        if (a[i-1] - a[i] > m) {
            a[i] = a[i-1] - m;
            ans++;
        }
    }
    cout << min(best, ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -