제출 #333301

#제출 시각아이디문제언어결과실행 시간메모리
333301AmineTrabelsiRabbit Carrot (LMIO19_triusis)C++14
0 / 100
1 ms384 KiB
#include "bits/stdc++.h"
using namespace std;
// Hi ☻
int n,m; // towerscnt, mxjump
vector<int> h;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    h.assign(n+1,0);
    for(int i = 1;i<=n;i++)cin>>h[i];
    vector<int> reach(n+1,0); // reach[i] max height possible to get to this
    vector<int> ans(n+1,0);
    for(int i=0;i<n;i++){
        // get max height possible up to i+1, with least changes possible
        ans[i+1] = ans[i];
        if(reach[i]+m >= h[i+1]){
            // don't change anything
            reach[i+1] = h[i+1];
        }else{
            reach[i+1] = reach[i]+m;
            ans[i+1] ++;
        }
         // cout<<reach[i+1]<<" ";
    }
    // cout<<endl;
    cout<< ans[n] << '\n';
    return 0;
}
/*
5 400
300
700
200
1000
500

3 300
700
1000
1300
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...