이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long delivery(int N, int K, int L, int p[]) {
ll answer = 0;
for (int i=0; i<N; i++){
answer = answer + min(p[i],L-p[i])*2;
}
if (K==1) return answer;
answer = 0;
if (L==1) return answer;
int mxd = N/2;
int cnt = 0, cntright = 0;
for (int i=0; i<N; i++){
if (p[i] <= mxd) cnt++;
if ((p[i] == 0 || p[i] >= mxd+1) && N%2==1) cntright++;
else if ((p[i] == 0 || p[i] >= mxd) && N%2==0) cntright++;
}
if (cnt == N) return 2LL*p[N-1];
if (cntright == N) return 2LL*(L-p[0]);
answer = L;
ll maxleft, maxright;
maxleft = maxright = 0;
for (int i=0; i<N; i++){
if (p[i] <= mxd){
maxleft = max(maxleft,(ll)p[i]);
}else{
maxright = max(maxright, (ll)L-p[i]);
}
}
ll answer2 = maxleft*2LL + maxright*2LL;
answer = min(answer, answer2);
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... |