Submission #71200

#TimeUsernameProblemLanguageResultExecution timeMemory
71200fallingstarBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#include "boxes.h" #include <algorithm> using namespace std; #define long long long const int N = 2e7 + 2; long fsuff[N], fpref[N]; long delivery(int n, int k, int L, int p[]) { int head = 0; while (head < n && p[head] == 0) ++head; long res = (long) (n - head + k - 1) / k * L; for (int i = n - 1; i >= head; --i) fsuff[i] = fsuff[i + k] + (L - p[i]) * 2; int full = 0; while ((full + 1) * k <= n - head && fsuff[head + (full + 1) * k] + L < fsuff[head + full * k]) ++full; for (int i = head; i < n; ++i) { fpref[i] = (i < k ? 0 : fpref[i - k]) + p[i] * 2; #define eval(x) (fsuff[i + 1 + x * k] + x * L) while (full > 0 && eval(full - 1) < eval(full)) --full; res = min(res, fpref[i] + eval(full)); #undef eval } return res; }
#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...