Submission #541515

#TimeUsernameProblemLanguageResultExecution timeMemory
541515JomnoiBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
593 ms293800 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; const int MAX = 1e7 + 10; const long long INF = 1e18 + 7; long long pre[MAX], suf[MAX]; long long delivery(int N, int K, int L, int p[]) { for(int i = 1; i <= N; i++) { pre[i] = pre[max(0, i - K)] + p[i - 1] + min(p[i - 1], L - p[i - 1]); } for(int i = N; i >= 1; i--) { suf[i] = suf[min(N + 1, i + K)] + (L - p[i - 1]) + min(p[i - 1], L - p[i - 1]); } long long ans = INF; for(int i = 0; i <= N; i++) { ans = min(ans, pre[i] + suf[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...