#include <bits/stdc++.h>
using namespace std;
#define lli long long
#define pii pair<lli, lli>
#define f first
#define s second
#define pb push_back
#define inf 1e9
const lli LOG = 31;
#define endl '\n'
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, k; cin >> n >> k;
int last = 0;
int resp=0;
bool mod_f = false;
for (int i=0; i<n; i++){
int x; cin >> x;
if (last ==0 && x-last>k){
x = k;
resp++;
mod_f=true;
}
if (!mod_f){
if (x-last>k){
resp++;
}
}else{
if (x-last>k){
x = last+k;
resp++;
}
}
last=x;
}
cout << resp;
}
# | 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... |