# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
693936 | T0p_ | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 340 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;
const int N = 10000000;
long long cw[N+5], ccw[N+5];
long long delivery(int N, int K, int L, int p[])
{
for (int i=0 ; i<K ; i++) cw[i] = p[i];
for (int i=K ; i<N ; i++) cw[i] = cw[i-K] + p[i] + p[i-K];
for (int i=0 ; i<K ; i++) ccw[N-i-1] = L - p[N-i-1];
for (int i=K ; i<N ; i++) ccw[N-i-1] = ccw[N-i+K-1] + L - p[N-i+K-1] + L - p[N-i-1];
long long ans = 1e18;
for (int i=0 ; i<=N ; i++)
{
if (i == 0) ans = min(ans, ccw[0] + L - p[0]);
else if (i == N) ans = min(ans, cw[N-1] + p[N-1]);
else ans = min(ans, cw[i-1] + p[i-1] + ccw[i] + L - p[i]);
}
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... |