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;
int pref[10000002];
int suf[10000002];
int delivery(int n, int k, int l, int positions[]){
for (int i = 0; i<k; i++)pref[i]=positions[i];
for (int i = k; i<n; i++)pref[i]=positions[i]+pref[i-k];
for (int i = n-1; i>n-k-1; i--)suf[i]=l-positions[i];
for (int i = n-k-1; i>=0; i--)suf[i]=l-positions[i]+suf[i+k];
int ans=suf[0];
for (int i = 0; i<n-1; i++)ans=min(ans,2*pref[i]+2*suf[i+1]);
for (int i = 0; i<n-1; i++)ans=min(ans,2*pref[i]+l+2*(i+k<n ? suf[i+k] : suf[n-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... |