Submission #314157

#TimeUsernameProblemLanguageResultExecution timeMemory
314157joseacazBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
528 ms196096 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef vector<int> vi; const int MAXN = 1e7 + 5; int N, K, L; ll pre[MAXN], suf[MAXN]; ll delivery(int _n, int _k, int _l, int p[]) { N = _n, K = _k, L = _l; for(int i = 0; i < N; i++) pre[i] = (i - K >= 0 ? pre[i - K] : 0) + 2*p[i]; for(int i = N - 1; i >= 0; i--) suf[i] = (i + K < N ? suf[i + K] : 0) + 2*(L-p[i]); ll ans = min(min(pre[N - 1], suf[0]), min(L + suf[K], pre[N - K - 1] + L)); for(int i = 0; i < N - 1; i++) ans = min(ans, pre[i] + suf[i + 1]); for(int i = 0; i < N - K - 1; i++) ans = min(ans, pre[i] + suf[i + K + 1] + 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...