Submission #413789

#TimeUsernameProblemLanguageResultExecution timeMemory
413789ak2006Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
581 ms293944 KiB
#include "boxes.h" using namespace std; #include <bits/stdc++.h> #define ll long long #define vl vector<ll> long long delivery(int n, int k, int L, int pos[]) { vl pref(n),suf(n); for (int i = 0;i<n;i++)pref[i] = 1ll * 2 * 1ll * pos[i] + (i >= k ? pref[i - k] : 0); for (int i = n - 1;i>=0;i--)suf[i] = 1ll * 2 * 1ll * (1ll * L - 1ll * pos[i]) + (i + k < n ? suf[i + k] : 0); ll ans = min(pref[n - 1],suf[0]); for (int i = 0;i<n - 1;i++)ans = min(ans,pref[i] + suf[i + 1]); for (int i = 0;i<n;i++) ans = min(ans,(i >= 1 ? pref[i - 1] : 0) + (i + k < n ? suf[i + k] : 0) + 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...