Submission #754472

#TimeUsernameProblemLanguageResultExecution timeMemory
754472sofija6Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
556 ms222260 KiB
#include "boxes.h" #include <bits/stdc++.h> #define MAXN 10000010 using namespace std; long long pref[MAXN],suff[MAXN]; long long delivery(int N, int K, int L, int p[]) { for (int i=0;i<N;i++) pref[i+1]=pref[max(0,i+1-K)]+2*p[i]; for (int i=N-1;i>=0;i--) suff[i+1]=suff[min(N+1,i+1+K)]+2*(L-p[i]); long long ans=LLONG_MAX; for (int i=0;i<=N;i++) ans=min({ans,pref[i]+suff[i+1],pref[i]+L+suff[min(N+1,i+K+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...