Submission #476539

#TimeUsernameProblemLanguageResultExecution timeMemory
476539dsyzRabbit Carrot (LMIO19_triusis)C++14
0 / 100
1 ms204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...