이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <iostream>
using namespace std;
//#teams, capacity, #sections, position of each team
long long delivery(int N, int K, int L, int positions[])
{
long long dp_inc[N]; //minimum time needed to cover all 0, 1, ... i and end up at positions[[i]
dp_inc[0] = min(positions[0], L - positions[0]);
for(int i = 1; i < N; i++)
{
if(i % K == 0)
{
dp_inc[i] = dp_inc[i-1] + min(positions[i-1], L - positions[i-1]) + min(positions[i], L - positions[i]);
}
else
{
dp_inc[i] = dp_inc[i-1] + (positions[i] - positions[i-1]);
}
}
for(int i = 0; i < N; i++) cout << dp_inc[i] << ' ';
cout << '\n';
long long dp_dec[N];
dp_dec[N-1] = min(positions[N-1], L - positions[N-1]);
for(int i = N-2; i >= 0; i--)
{
if((N - 1 - i) % K == 0)
{
dp_dec[i] = dp_dec[i+1] + min(positions[i+1], L - positions[i+1]) + min(positions[i], L - positions[i]);
}
else
{
dp_dec[i] = dp_dec[i+1] + (positions[i+1] - positions[i]);
}
}
//for(int i = 0; i < N; i++) cout << dp_dec[i] << ' ';
//cout << '\n';
long long res = (long long)(1000 * 1000 * 1000) * (long long)(1000 * 1000 * 1000);
for(int i = 0; i < N; i++)
res = min(res, dp_inc[i] + dp_dec[i+1] + min(positions[i], L - positions[i]) + min(positions[i+1], L - positions[i+1]));
res = min(res, dp_inc[N-1] + /**/(dp_dec[N-1]));
res = min(res, dp_dec[0] + /**/(dp_inc[0]));
return res;
}
| # | 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... |