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>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using ll=long long;
const int mxN = 1e7;
ll d[mxN];
ll delivery(int N, int K, int L, int p[]) {
int half = -1;
FOR(i,0,N-1){
if (p[i]*2 <= L) d[i] = (i < K ? 0 : d[(i/K)*K-1]) + p[i], half = i;
else d[i] = (N-1-i < K ? 0 : d[N-1-((N-1-i)/K*K-1)]) + (L-p[i]);
}
d[N] = 0;
ll ans = 2*d[half] + 2*d[half+1];
FOR(i,0,min(half,N-K)){
if (i == N-K || p[i+K]*2 > L) {
ans = min(ans,2*(i > 0 ? d[i-1] : 0)+L+2*d[i+K]);
}
}
//TRACE(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... |