Submission #595179

#TimeUsernameProblemLanguageResultExecution timeMemory
595179KrisjanisPBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
494 ms259672 KiB
#include "boxes.h" #include <bits/stdc++.h> #define INF 1e18 using namespace std; using ll = long long; long long delivery(int N, int K, int L, int p[]) { ll l[N+1], r[N+1]; l[0] = r[0] = 0; for(ll i=1;i<=N;i++) { l[i] = l[max(i-K,0ll)]+p[i-1]*2; r[i] = r[max(i-K,0ll)]+(L-p[N-i])*2; } ll res = INF; for(ll tl=0;tl<=N;tl++) { ll tr = N-tl; res = min(res,l[tl]+r[tr]); ll tr2 = max(N-tl-K,0ll); res = min(res,l[tl]+r[tr2]+L); } return res; }
#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...