제출 #563586

#제출 시각아이디문제언어결과실행 시간메모리
563586hoanghq2004선물상자 (IOI15_boxes)C++14
100 / 100
544 ms262088 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "boxes.h" using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 1e7 + 10; long long f[N], g[N]; int p[N]; long long delivery(int n, int k, int l, int P[]) { for (int i = 0; i < n; ++i) p[i + 1] = P[i]; for (int i = 1; i <= n; ++i) f[i] = f[max(0, i - k)] + 2 * p[i]; for (int i = n; i >= 1; --i) g[i] = g[min(n + 1, i + k)] + 2 * (l - p[i]); long long ans = 1e18; k = min(k, n); for (int i = 0; i <= n; ++i) ans = min(ans, f[i] + g[i + 1]); for (int i = 1; i <= n; ++i) { int j = min(i + k, n + 1); ans = min(ans, f[i - 1] + g[j] + l); } return ans; } // //int main() { // freopen("test.inp", "r", stdin); // ios :: sync_with_stdio(0); cin.tie(0); // int n, k, l; // cin >> n >> k >> l; // int p[n]; // for (int i = 0; i < n; ++i) cin >> p[i]; // cout << delivery(n, k, l, p); //}
#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...