Submission #1045501

#TimeUsernameProblemLanguageResultExecution timeMemory
1045501dimasnbayuSafety (NOI18_safety)C++14
0 / 100
26 ms2576 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n,m,ans=0; cin>>n>>m; int arr[n+1]; for(int i=1;i<=n;i++) cin>>arr[i]; for(int i=2;i<=n;i++){ if(abs(arr[i]-arr[i-1])>m){ ans+=(abs(arr[i]-arr[i-1])-m); if(arr[i]>arr[i-1]) arr[i]-=(abs(arr[i]-arr[i-1])-m); else arr[i]+=(abs(arr[i]-arr[i-1])-m); } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...