# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71779 | zubec | Boxes with souvenirs (IOI15_boxes) | C++14 | 3 ms | 476 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 N = 10000010;
int n, k, l, a[N];
long long delivery(int N, int K, int L, int p[]) {
ll ans1 = 0, ans2 = 0;
n = N;
k = K;
l = L;
for (int i = 1; i <= n; i++)
a[i] = p[i-1];
for (int i = 1; i <= n; i+=k){
int nxt = min(n, i+k-1);
ans1 += min(a[i], l-a[i]);
ans1 += abs(a[i]-a[nxt]);
ans1 += min(a[nxt], l-a[nxt]);
}
reverse(a+1, a+n+1);
for (int i = 1; i <= n; i+=k){
int nxt = min(n, i+k-1);
ans2 += min(a[i], l-a[i]);
ans2 += abs(a[i]-a[nxt]);
ans2 += min(a[nxt], l-a[nxt]);
}
return min(ans1, ans2);
}
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... |