제출 #646821

#제출 시각아이디문제언어결과실행 시간메모리
646821Alex_tz307선물상자 (IOI15_boxes)C++17
100 / 100
435 ms196044 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; const int kN = 1e7; const int64_t INF = 1e18L; int64_t l[1 + kN], r[1 + kN + 1]; void minSelf(int64_t &x, int64_t y) { if (y < x) { x = y; } } long long delivery(int n, int k, int L, int p[]) { for (int i = 1; i <= n; ++i) { int last = max(0, i - k); l[i] = l[last] + p[i - 1] + min(p[i - 1], L - p[i - 1]); } for (int i = n; i > 0; --i) { int nxt = min(n + 1, i + k); r[i] = r[nxt] + (L - p[i - 1]) + min(p[i - 1], L - p[i - 1]); } int64_t best = INF; for (int i = 0; i <= n; ++i) { minSelf(best, l[i] + r[i + 1]); } return best; }
#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...