This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N,M;
cin>>N>>M;
ll arr[N + 1];
memset(arr,0,sizeof(arr));
for(ll i = 1;i <= N;i++){
cin>>arr[i];
}
ll sum = 0;
for(ll i = 1;i <= N;i++){
if(arr[i] > arr[i - 1] + M){
arr[i] = arr[i - 1] + M;
sum++;
}else{
if(i < N - 1 && arr[i] + M < arr[i + 1] && arr[i - 1] + M + M >= arr[i + 1]){
arr[i] = arr[i - 1] + M + M;
sum++;
}
}
}
cout<<sum<<'\n';
}
# | 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... |