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 "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int oo = 1e9;
#include "boxes.h"
vector<ll> getCost(int n, int k, int p[]) {
vector<ll> pref(n+1);
vector<ll> p2(k);
for(int i=0;i<n;++i) {
p2[i%k]+=2*p[i];
pref[i+1]=pref[i]+p2[i%k];
}
return pref;
}
long long delivery(int N, int K, int L, int p[]) {
auto c1 = getCost(N,K,p);
reverse(p,p+N);
for(int i=0;i<N;++i) p[i] = L-p[i];
auto c2 = getCost(N,K,p);
reverse(all(c2));
ll ans = 1e18;
for(int i=0;i<=N;++i) {
ans = min(ans,c1[i]+c2[i]);
}
for(int i=0;i+K<=N;++i) {
ans = min(ans,L+c1[i]+c2[i+K]);
}
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... |