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 int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
long long P[10000005], S[10000005];
long long delivery(int N, int K, int L, int p[]) {
for(int i=1;i<=K;i++)P[i] = p[i-1] * 2;
for(int i=K+1;i<=N;i++)P[i] = P[i-K] + p[i-1] * 2;
for(int i=N;i>=N-K+1;i--)S[i] = (L - p[i-1])*2;
for(int i=N-K;i>=1;i--)S[i] = S[i+K] + (L - p[i-1]) * 2;
S[N+1] = 0;
long long ans = 1e18;
for(int i=0;i<=N;i++)ans = min(ans, P[i] + S[i+1]);
for(int i=K;i<=N;i++){
ans = min(ans, P[i-K] + S[i+1] + L);
}
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... |