# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830689 | drdilyor | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 300 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<bits/stdc++.h>
#include "boxes.h"
using ll = long long;
using namespace std;
long long delivery(int n, int k, int len, int p[]) {
int mid1 = len / 2;
int mid2 = (len+1) / 2;
ll res = 0;
int li = -1, ri = n;
for (int i =0; i < n; i++) {
if (p[i] > mid1) break;
if (i % k == k-1) {
li = i;
res += p[i] * 2;
}
}
for (int i = 0; i < n; i++) {
int j = n - i - 1;
if (p[j] < mid2) break;
if (i % k == k-1) {
ri = j;
res += (n - p[j]) * 2;
}
}
const ll infl = 1e18;
int cnt = ri - li - 1;
if (cnt <= k) {
res += min({len, p[li+1] * 2, (len - p[ri-1]) * 2});
} else {
res += len + min({len, p[li + k + 1] * 2, (len - p[ri - k - 1]) * 2});
}
return res;
}
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... |