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 INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
int p1[10000010], p2[10000010];
long long delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) {
int k=K, n=N, l=L;
for(int i=0; i<n; i++){
if(i>=k){
p1[i]=p1[i-k]+p[i]*2;
}
else{
p1[i]=(p[i]*2);
}
}
for(int i=n-1; i>=0; i--){
if((n-1-i)>=k){
p2[i]=p2[i+k]+(l-p[i]) *2;
}
else{
p2[i]=(l-p[i]) *2;
}
}
int res=1e18;
res=min(res, p2[0]);
if(n>=k){
res=min(res, p2[k]+l);
}
for(int i=0; i<n; i++){
if(i>=k){
res=min(min(p1[i]+p2[i+1], p1[i-k]+l+p2[i+1]), res);
}
else{
res=min(p1[i]+p2[i+1], res);
}
}
if(k>=n){
res=min(res, l);
}
return res;
}
# | 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... |