Submission #594637

#TimeUsernameProblemLanguageResultExecution timeMemory
594637VanillaBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
524 ms292780 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long int64; const int maxn = 1e7 + 2; int64 l[maxn], r[maxn]; long long delivery(int n, int k, int m, int p[]) { for (int64 i = 1; i <= n; i++){ l[i] = l[max(0ll, i - k)] + min(1ll * p[i-1] * 2, 1ll * m); } reverse(p, p + n); for (int64 i = 1; i <= n; i++){ r[i] = r[max(0ll, i - k)] + min(1ll * (m - p[i-1]) * 2, 1ll * m); // cout << i << " " << r[i] << "\n"; } int64 rs = 1e18; for (int64 i = 0; i <= n; i++){ // cout << i << " " << l[i] << " " << r[n - i] << "\n"; rs = min(rs, l[i] + r[n - i]); } return rs; }
#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...