# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
693934 | T0p_ | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 468 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[])
{
cw[0] = p[0];
for (int i=1 ; i<N ; i++)
{
cw[i] = cw[i-1];
if (i % K == 0) cw[i] += 2 * p[i-1];
cw[i] += p[i] - p[i-1];
}
ccw[N-1] = L - p[N-1];
for (int i=N-2 ; i>=0 ; i--)
{
ccw[i] = ccw[i+1];
if ((N - i - 1) % K == 0) ccw[i] += 2 * (L - p[i+1]);
ccw[i] += p[i+1] - p[i];
}
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] + 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... |