이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 10000010
lld l[MAXN], r[MAXN];
int dist(int pos, int L) {
return min(pos, L-pos);
}
lld delivery(int N, int K, int L, int pos[]) {
for(int i = 0; i < K; i++) l[i] = dist(pos[i], L) + pos[i];
for(int i = K; i < N; i++) l[i] = dist(pos[i], L) + pos[i] + l[i-K];
for(int i = 0; i < K; i++) r[i] = dist(pos[N-1-i], L) + L-pos[N-1-i];
for(int i = K; i < N; i++) r[i] = dist(pos[N-1-i], L) + L-pos[N-1-i] + r[i-K];
lld rez = min(l[N-1], r[N-1]);
for(int i = 0; i < N-1; i++) rez = min(rez, l[i]+r[N-2-i]);
return rez;
}
# | 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... |