이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
const ll INF = __LONG_LONG_MAX__;
int n, k, l;
int posicionCW[10000002];
ll CW[10000001], AW[10000002];
long long delivery(int N, int K, int L, int p[]) {
n = N, k=K, l = L;
for(int i = 0 ; i < n ; i ++)posicionCW[i]=p[i];
for(int i = 0 ; i < n ; i ++){
if(i+1<=k)CW[i]=2*posicionCW[i];
else CW[i] = CW[i-k] + 2*posicionCW[i];
//cout<<CW[i]<<" ";
}
//cout<<endl;
for(int i = n-1 ; i >= 0 ; i--){
if(i>=n-k)AW[i]=2*(l-posicionCW[i]);
else AW[i] = AW[i+k] + 2* (l-posicionCW[i]);
//cout<<AW[i]<< " ";
}
//cout<<endl;
ll ans = AW[0];
ans = min(ans, AW[0]- (l-posicionCW[0]) + posicionCW[0]);
//ans = min(ans, CW[n-1] - posicionCW[n-1] + (l-posicionCW[n-1]));
AW[n]=0;
posicionCW[n]=l;
for(int i = 0 ; i < n ; i++){
ans = min(ans, CW[i] + AW[i+1]);
ans = min (ans, CW[i] + AW[i+1]- abs(l-posicionCW[i+1]) + posicionCW[i+1]);
ans = min(ans, CW[i] - posicionCW[i] + abs(l-posicionCW[i]) + AW[i+1]);
cout<<i<<" "<<ans<<endl;
}
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... |