This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000000000000000
#define md 1000000007
#define li 10000005
#define mp make_pair
#define pb push_back
using namespace std;
vector<lo int> l, r;
lo int ans = inf;
long long delivery(int N, int K, int L, int positions[]){
for(int i = 0;i < N; i ++){
if(positions[i] <= L / 2){
l.pb(positions[i] * 2);
}
else{
r.pb( 2 * L - positions[i] * 2);
}
}
reverse(r.begin(),r.end());
for(int i = K;i < (int)l.size(); i ++){
l[i]+=l[i-K];
}
for(int i = K;i < (int)r.size(); i ++){
r[i] += r[i - K];
}
for(int i = 0;i <= K; i ++){
int x = i;
int y = K - i;
ans = min(ans, (x<(int)l.size()?l[l.size()-1-x]:0)+(y<(int)r.size()?r[r.size()-1-y]:0)+L);
}
ans=min(ans,((int)l.size()>0?l.back():0)+((int)r.size()>0?r.back():0));
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... |