Submission #284526

#TimeUsernameProblemLanguageResultExecution timeMemory
284526IOrtroiiiBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
584 ms210680 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<long long> pref(N + 1); vector<long long> suff(N + 1); for (int i = 0; i < N; ++i) { pref[i + 1] = 2 * p[i]; if (i >= K) pref[i + 1] += pref[i + 1 - K]; } for (int i = N - 1; i >= 0; --i) { suff[i] = 2 * (L - p[i]); if (i + K <= N) suff[i] += suff[i + K]; } long long ans = 1e18; for (int i = 0; i <= N; ++i) { ans = min(ans, pref[i] + suff[i]); if (i + K <= N) ans = min(ans, pref[i] + suff[i + K] + L); } return 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...