제출 #588434

#제출 시각아이디문제언어결과실행 시간메모리
588434lorenzoferrari선물상자 (IOI15_boxes)C++17
100 / 100
508 ms198552 KiB
#include "boxes.h" #pragma GCC optimize ("O3") #include <bits/stdc++.h> using namespace std; using LL = long long; inline vector<LL> linear_cost(int n, int k, int p[]) { vector<LL> ans(n+1); ans[0] = 0; for (int i = 1; i <= n; ++i) { ans[i] = 2 * p[i-1] + ans[max(0, i - k)]; ans[i] = max(ans[i], ans[i-1]); // case p[n-1] = 0... } return ans; } LL delivery(int n, int k, int l, int p[]) { auto ca = linear_cost(n, k, p); for (int i = 0; i < n; ++i) p[i] = (p[i] ? l - p[i] : 0); reverse(p, p + n); auto cb = linear_cost(n, k, p); LL ans = 1e18; for (int i = 0; i <= n; ++i) { ans = min(ans, ca[i] + cb[n - i]); } for (int a = 0; a < n; ++a) { int b = min(n, a + k); ans = min(ans, l + ca[a] + cb[n - b]); } 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...