이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long delivery(int N, int K, int L, int p[]) {
//vector<ll> p(N);
//for(int i = 0; i<n; i++) p[i] = pp[i];
ll ans = 1e18;
int mid = (L)/2;
int midind = N;
for(int i =0; i<N; i++){
if(p[i] > mid){
midind = i;
break;
}
}
//cout << midind<<endl;
for(int first = 0; first< N; first++){
ll curans = 0;
//cout << first<<":: "<<endl;
for(int rng = first; rng < N + first; rng += K){
int start = rng;
int end = start + K -1;
int mstart = start % N;
int mend = end % N;
if(end - N >= first){
end = first - 1 + N;
mend = end % N;
}
if(end < N){
//cout <<start<<", "<<end<< ": "<< p[start]<<", "<<p[end]<<endl;
if(end< midind){//if they are alll in first half
curans += 2 * p[end];
}
//all in second half
else if(start >= midind){
curans += 2 * ( L - p[start]);
}
else{
curans += min(L, 2*p[midind - 1] + 2 * p[midind]);
}
}
else{
if( start < N){
if(start < midind){
curans += L;
}
else if(mend >= midind){
curans += L;
}
else{
curans += max(L , 2 * p[mend] + 2 * p[start]);
}
}
else{
if(mend< midind){//if they are alll in first half
curans += 2 * p[mend];
}
//all in second half
else if(mstart >= midind){
curans += 2 * ( L - p[mstart]);
}
else{
curans += min(L, 2*p[midind - 1] + 2 * p[midind]);
}
}
}
// do circle
//cout << rng<<": "<<curans<<" ";
}
//cout <<":: "<<curans<<endl<<endl;
ans = min(curans, ans);
}
return ans;
}
/************/
# | 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... |