Submission #393219

#TimeUsernameProblemLanguageResultExecution timeMemory
393219peuchBoxes 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] = p[i]; if(i >= k) l[i] += l[i - k]; } for(int i = N - 1; i >= 0; i--){ r[i] = (L - p[i]); if(i + k < N) r[i] += r[i + k]; } long long ans = n * L; for(int i = 0; i < N - 1; i++) ans = min(ans, 2 * l[i] + 2 * r[i + 1]); ans = min(ans, L + 2 * r[k]); ans = min(ans, L + 2 * l[N - k - 1]); for(int i = 1; i + k < N; i++) ans = min(ans, 2 * l[i - 1] + L + 2 * 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...