제출 #1284406

#제출 시각아이디문제언어결과실행 시간메모리
1284406zxzuamRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms580 KiB
#include <bits/stdc++.h>
#define int int64_t
using ll = int64_t;
using namespace std;
constexpr int maxn = 1E5 + 1;
void orz() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n + 1);
    for(int i = 1; i <= n; i++ ){
        cin >> a[i];
    }
    int ans = 0;
    if(a[1] > k) {
        a[1] = k;
        ans++;
    }
    for(int i = 2; i <= n; i++){
        if(a[i] > a[i - 1] + k) {
            ans++;
            if(a[i - 2] + (2 * k) >= a[i]) {
                a[i - 1] = a[i - 2] + k;
            }
            else{
                a[i] = a[i - 1] + k;
            }
        }
    }
    cout << ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    //freopen("promote.in", "r", stdin);
    //freopen("promote.out", "w", stdout);
    int T = 1;
    //cin >> T;
    while(T--) orz();
    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...