# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
787034 | GusterGoose27 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e7+5;
ll pre[MAXN];
ll delivery(int n, int k, int l, int p[]) {
ll cur = 0;
int res = 0;
int s = 0;
for (int i = 0; i < n && p[i] <= l/2; i++) {
pre[i] = cur+2*p[i];
if (res == k-1) {
cur += 2*p[i];
res = 0;
continue;
}
res++;
}
cur = 0;
res = 0;
for (int i = n-1; i >= 0 && p[i] > l/2; i--) {
pre[i] = cur+2*(l-p[i]);
if (res == k-1) {
cur += 2*(l-p[i]);
res = 0;
continue;
}
res++;
}
int div;
for (div = 0; div < n && p[div] <= l/2; div++) {}
ll ans = (div ? pre[div-1] : 0) + pre[div];
for (int i = div-k+1; i < div; i++) {
int lp = max(i, 0);
int rp = min(n-1, i+k-1);
ans = min(ans, (lp ? pre[lp-1] : 0)+pre[rp+1]+l);
}
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... |