Submission #427794

#TimeUsernameProblemLanguageResultExecution timeMemory
427794timmyfengBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
553 ms199436 KiB
#include <bits/stdc++.h> using namespace std; #include "boxes.h" const int N = 10000001; long long cw[N], ccw[N]; long long delivery(int n, int k, int l, int p[]) { for (int i = 1; i <= n; ++i) { cw[i] = 2 * p[i - 1] + (i - k < 0 ? 0 : cw[i - k]); } for (int i = n - 1; i >= 0; --i) { ccw[i] = 2 * (l - p[i]) + (i + k > n ? 0 : ccw[i + k]); } long long ans = LLONG_MAX; for (int i = 0; i <= n; ++i) { ans = min({ans, cw[i] + ccw[min(n, i + k)] + l, cw[i] + ccw[i]}); } 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...