Submission #393226

#TimeUsernameProblemLanguageResultExecution timeMemory
393226peuchBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms332 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 1e7 + 10; long long l[MAXN], r[MAXN]; long long delivery(int N, int K, int L, int p[]) { long long n = N; long long k = K; for(int i = 0; i < N; i++){ l[i] = 2 * p[i]; if(i >= k) l[i] += l[i - k]; } for(int i = N - 1; i >= 0; i--){ r[i] = 2 * (L - p[i]); if(i + k < N) r[i] += r[i + k]; } long long ans = 1e18; for(int i = 0; i < N - 1; i++) ans = min(ans, l[i] + r[i + 1]); if(k == n) ans = min(ans, (long long)L); else ans = min(ans, L + r[k]), ans = min(ans, l[n - k - 1] + L); for(int i = 1; i + k < n; i++) ans = min(ans, l[i - 1] + L + r[i + k]); 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...