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 F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
lli arr[10000000],arr1[10000000],ans=0;
long long delivery(int N, int K, int L, int p[])
{
lli n,k,l;
n=N;
k=K;
l=L;
for(lli i=0;i<n;++i)
{
arr[i]=p[i]*2+((i-k>=0)?arr[i-k]:0*1LL);
}
for(lli i=n-1;i>=0*1LL;--i)
arr1[i]=(l-p[i])*2+((i+k<=n-1)?arr1[i+k]:0*1LL);
ans=min(arr[n-1],arr1[0*1LL]);
for(lli i=0*1LL;i<n-1;++i)
ans=min(ans,arr[i]+arr1[i+1]);
for(lli i=0*1LL;i<=n;++i)
ans=min(ans,((i>0*1LL)?arr[i-1]:0*1LL)+l+((n-i-k>0*1LL)?arr1[(n)-(n-k-i)]:0*1LL));
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... |