Submission #141528

#TimeUsernameProblemLanguageResultExecution timeMemory
141528meatrowSafety (NOI18_safety)C++17
0 / 100
21 ms376 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") //#pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, h; cin >> n >> h; ll ans = 0; ll kek = 0; int s; cin >> s; for (int i = 1; i < n; i++) { int t; cin >> t; if (t > s + h) { kek += t - s - h; } else { if (t < s - h) { kek += t - s + h; } else { kek = 0; } } ans += abs(kek); s = t; } cout << ans; return 0; }
#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...