This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
ll delivery (int n, int k, int len, int pos[])
{
ll lTime[n], rTime[n];
for(int i = 0; i < n; i++)
{
if(i - k >= 0)
lTime[i] = lTime[i - k];
else
lTime[i] = 0;
lTime[i] += pos[i] * 2;
}
for(int i = n - 1; i >= 0; i--)
{
if(i + k < n)
rTime[i] = rTime[i + k];
else
rTime[i] = 0;
rTime[i] += (len - pos[i]) * 2;
}
ll answer = LLONG_MAX;
/// Taking no full circle
for(int i = 0; i <= n; i++)
{
ll time = 0;
if(i > 0)
time += lTime[i - 1];
if(i < n)
time += rTime[i];
answer = min(answer, time);
}
/// Taking one full circle
for(int i = 0; i + k <= n; i++)
{
ll time = len;
if(i > 0)
time += lTime[i - 1];
if(i + k < n)
time += rTime[i + k];
answer = min(answer, time);
}
return answer;
}
# | 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... |