Submission #330025

#TimeUsernameProblemLanguageResultExecution timeMemory
330025mihai145Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
574 ms294124 KiB
#include "boxes.h" #include <bits/stdc++.h> const int NMAX = 1e7; long long pref[NMAX + 2], suf[NMAX + 2]; long long delivery(int N, int K, int L, int p[]) { for(int i = 0; i < N; i++) { pref[i] = 2 * p[i]; if(i >= K) pref[i] += pref[i - K]; } for(int i = N - 1; i >= 0; i--) { suf[i] = 2 * (L - p[i]); if(i + K < N) suf[i] += suf[i + K]; } long long sol = std::min(pref[N - 1], suf[0]); for(int i = 0; i < N - 2; i++) { sol = std::min(sol, pref[i] + suf[i + 1]); } if(K >= N) sol = std::min(sol, 1LL * L); for(int i = 0; i < N - 2; i++) { long long cost = pref[i] + L; if(i + K + 1 < N) cost += suf[i + K + 1]; sol = std::min(sol, cost); } return sol; }
#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...