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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int K = 1e7;
ll S[K];
ll delivery(int n, int k, int L, int P[]){
vector<ll> A(n+1), B(n+1);
A[0] = 0, B[n] = 0;
fill(S, S+k, 0);
for(int i = 1; i <= n; i++){
S[i%k]+=2*P[i-1];
A[i] = S[i%k];
}
fill(S, S+k, 0);
for(int i = n-1; i >= 0; i--){
S[(n-i)%k]+=2*(L-P[i]);
B[i] = S[(n-i)%k];
}
vector<ll> C(n+1);
C[n] = 0;
for(int i = n-1; i >= 0; i--){
C[i] = ll((n-i+k-1)/k)*L;
C[i] = min(C[i], B[i]);
if(i+k <= n) C[i] = min(C[i], C[i+k]+L);
}
ll ans = 1e18;
for(int i = 0; i <= n; i++) ans = min(ans, A[i]+C[i]);
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... |