Submission #432405

#TimeUsernameProblemLanguageResultExecution timeMemory
432405snasibov05Boxes with souvenirs (IOI15_boxes)C++14
25 / 100
1 ms288 KiB
#include "boxes.h" #include <vector> #include <algorithm> using namespace std; #define ll long long #define pii pair<int, int> #define oo 1000000000000000000ll long long delivery(int n, int k, int l, int p[]) { vector<ll> pref(n), suf(n+1); for (int i = 0; i < n; ++i) { if (i - k >= 0) pref[i] = pref[i-k]; if (p[i] < l/2) pref[i] += 2ll*p[i]; else pref[i] += l; } for (int i = n-1; i >= 0; --i) { if (i + k < n) suf[i] = suf[i+k]; if (p[i] > l/2) suf[i] += 2ll*(l - p[i]); else suf[i] += l; } ll ans = suf[0]; for (int i = 0; i < n; ++i) { ans = min(ans, pref[i] + suf[i+1]); } 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...