이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
#define INF 1'000'000'000'000'000'000
#define ABS(a) ((a) > 0 ? (a) : -(a))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
std::vector<long long> people;
long long delivery(int N, int K, int L, int p[])
{
people.resize(N+2);
people[0] = 0;
for (int i = 0; i < N; ++i)
people[i+1] = p[i];
people[N+1] = 0;
long long best = INF;
for (int i = 1; i <= K; ++i)
{
long long sum = 0;
int pos = 0;
sum += (pos+i <= N ? people[pos+i] : L) - people[pos];
pos += i;
while (pos <= N)
{
sum += MIN(people[pos], L - people[pos]);
sum += MIN(people[pos+1], L - people[pos+1]);
sum += (pos+K <= N ? people[pos+K] : L) - people[pos+1];
pos += K;
}
best = std::min(best, sum);
}
return best;
}
# | 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... |