# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604281 | 8e7 | Boxes with souvenirs (IOI15_boxes) | C++17 | 479 ms | 199436 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 10000005
#define pii pair<int, int>
#define ff first
#define ss second
#include "boxes.h"
const ll inf = 1LL<<60;
ll pref[maxn], suf[maxn];
long long delivery(int n, int K, int L, int p[]) {
for (int i = 0;i < n;i++) {
pref[i] = 2 * p[i];
if (i >= K) pref[i] += pref[i-K];
}
pary(pref, pref + n);
for (int i = n - 1;i >= 0;i--) {
suf[i] = 2 * (L - p[i]);
if (i < n - K) suf[i] += suf[i+K];
}
pary(suf, suf + n);
ll ans = suf[0];
for (int i = 0;i < n;i++) {
ans = min(ans, pref[i] + suf[i+1]);
}
ans = min(ans, L + suf[K]);
for (int i = 0;i + K + 1 <= n;i++) {
ans = min(ans, pref[i] + L + suf[i+K+1]);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |