이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |