이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int n, k, x;
ll pre[MAXN], pos[MAXN];
long long delivery(int N, int K, int L, int p[]) {
n=N; k=K; x=L;
// for(int i=1; i<=n; i++) p[i-1]=p[i-1];
sort(p, p+n);
for(int i=1; i<=n; i++) {
ll volta=min(p[i-1], x-p[i-1]);
pre[i]=volta+p[i-1];
pre[i]+= i-k>=0 ? pre[i-k] : 0;
}
for(int i=n; i>=1; i--) {
ll volta=min(p[i-1], x-p[i-1]);
pos[i]=volta+(x-p[i-1]);
pos[i]+= i+k<=n ? pos[i+k] : 0;
}
ll respf=x; respf*=n;
for(int i=0; i<=n; i++) respf=min(respf, (ll)pre[i]+pos[i+1]);
return respf;
}
| # | 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... |