Submission #203792

#TimeUsernameProblemLanguageResultExecution timeMemory
203792dennisstarSafety (NOI18_safety)C++17
0 / 100
93 ms2792 KiB
#include <bits/stdc++.h> #define em emplace using namespace std; typedef long long ll; priority_queue<ll> L, R; int N; ll H, S, A; int main() { cin>>N>>H; for (int i=1; i<=N; i++) { cin>>S; if (i==1) { L.em(S), R.em(-S); continue; } if (S<L.top()-H*(i-1)) A+=(L.top()-H*(i-1))-S, L.em(S+H*(i-1)); else if (S>-R.top()+H*(i-1)) A+=S+R.top()-H*(i-1), R.em(-S+H*(i-1)); else L.em(S+H*(i-1)), R.em(-S+H*(i-1)); } cout<<A<<'\n'; 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...