# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30544 | kavun | Boxes with souvenirs (IOI15_boxes) | C++14 | 3 ms | 424 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>
#define pb push_back
using namespace std;
long long n,l,k,ans = 1e18, cw[10000010], ccw[10000010], lmid = -1, rmid = -1;
long long delivery(int N, int K, int L, int p[]) {
n = N;
k = K;
for(int i = 0; i < n; i++)
{
if(p[i] <= L/2)
lmid = i;
if(p[i] > L/2)
{
rmid = i;
break;
}
}
for(int i = 0; i < k; i++)
cw[i] = 2*p[i];
for(int i = k; i < n; i++)
cw[i] = cw[i-k] + 2*p[i];
for(int i = n-1; i >= n-k; i--)
ccw[i] = 2*(L-p[i]);
for(int i = n-k-1; i >= 0; i--)
ccw[i] = ccw[i+k] + 2*(L-p[i]);
for(int i = 0; i < n; i++)
{
if(i + k >= n-1)
ans = min(ans,cw[i] + L);
else if(p[i+k] > L/2)
ans = min(ans,cw[i] + L + 2*ccw[i+k+1]);
}
long long ans2 = 0;
if(lmid > -1)
ans2 += cw[lmid];
if(rmid > -1)
ans2 += ccw[rmid];
ans = min(ans,ans2);
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... |