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>
#include "boxes.h"
using namespace std;
#define ll long long
ll delivery(int n, int k, int l, int p[]){
ll cw[n], ccw[n];
for (int i = 0; i < n; i++){
if (i - k < 0) cw[i] = 0;
else cw[i] = cw[i - k];
cw[i] += p[i] + min(p[i], l - p[i]);
}
for (int i = n - 1; i >= 0; i--){
if (i + k >= n) ccw[i] = 0;
else ccw[i] = ccw[i + k];
ccw[i] += (l - p[i]) + min(p[i], l - p[i]);
}
// for (int i = 0; i < n; i++) cout << cw[i] << ' '; cout << endl;
// for (int i = 0; i < n; i++) cout << ccw[i] << ' '; cout << endl;
ll re = min(cw[n - 1], ccw[0]);
for (int i = 1; i < n; i++){
re = min(re, cw[i - 1] + ccw[i]);
// cout << i << ' ' << re << endl;
}
return re;
}
# | 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... |