Submission #138465

#TimeUsernameProblemLanguageResultExecution timeMemory
138465DiuvenBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
611 ms292636 KiB
#include "boxes.h" typedef long long lint; const int MAX = 1e7+10; inline lint _min(lint a, lint b){ return a<b ? a : b; } lint A[MAX], B[MAX]; lint delivery(int n, int k, int L, int p[]) { for(int i=1; i<=n; i++) A[i] = (i-k>=0 ? A[i-k] : 0) + p[i-1] + _min(p[i-1], L-p[i-1]); for(int i=n; i>=1; i--) B[i] = (i+k<=n+1 ? B[i+k] : 0) + L-p[i-1] + _min(p[i-1], L-p[i-1]); lint ans = 2e18; for(int i=0; i<=n; i++) ans = _min(ans, A[i]+B[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...