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