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;
long long delivery(int n, int k, int l, int p[]) {
long long pref[n], suf[n];
for(int i = 0;i<n;i++) {
if(i >= k)pref[i] = pref[i-k] + min(p[i]*2, l);
else pref[i] = min(p[i]*2, l);
}
for(int i = n - 1;i>=0;i--) {
if(n - i - 1 >= k) {
suf[i] = min(l, 2*(l - p[i])) + suf[i+k];
}
else {
suf[i] = min(l, 2*(l - p[i]));
}
}
long long ans = min(suf[0], pref[n-1]);
for(int i = 0;i<n-1;i++) {
ans = min(ans, pref[i]+suf[i+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... |