이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____
||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... |