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;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 20000005;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
long long dp1[MAXN];
long long dp2[MAXN];
long long delivery(int n, int K, int L, int p[]) {
for(int i=1;i<=n;i++){
if(i%K){
int idx=i-i%K;
dp1[i]=dp1[idx]+2ll*p[i-1];
} else {
dp1[i]=dp1[i-K]+2ll*p[i-1];
}
}
for(int i=n;i>=1;i--){
int diff=n-i+1;
if(diff % K){
int idx=i+diff%K;
dp2[i]=dp2[idx]+2ll*(L-p[i-1]);
} else {
dp2[i]=dp2[i+K]+2ll*(L-p[i-1]);
}
}
long long ans=min(dp1[n],dp2[1]);
for(int i=1;i<=n;i++){
ans=min(ans,dp1[i]+(long long)L+dp2[i+K+1]);
}
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... |